A lightweight and production-ready ESP32 physical button project for triggering HTTP/HTTPS webhooks such as n8n, Home Assistant, Tasker APIs, ntfy notifications, and custom automation endpoints.
This project supports:
- Single physical button trigger
- Multi-action button trigger
- HTTPS webhook support
- n8n integration
- ntfy notifications
- Debounce handling
Perfect for:
- Home automation
- Smart desk buttons
- IoT webhook triggers
- Emergency buttons
- Task automation
- DIY smart home projects
- Single press action
- HTTPS GET webhook trigger
- ntfy success/failure notifications
- Stable debounce handling
- WiFi reconnect support
- Low CPU usage
- Optimized for continuous home usage
---
Supports:
| Action | Trigger |
|---|---|
| Single Press | Webhook URL 1 |
| Double Press | Webhook URL 2 |
| Long Press | Webhook URL 3 |
Additional features:
- Multi-click detection
- Long press detection
- Production-ready state handling
- Non-blocking logic using
millis()
- ESP32 Dev Board
- Push Button / Tactile Switch
- 2 Jumper Wires
- USB Cable
| ESP32 Pin | Button |
|---|---|
| GPIO 4 | Button Pin 1 |
| GND | Button Pin 2 |
Uses:
- Internal pull-up resistor
- No external resistor needed
+-------------------+
| ESP32 Boot |
+-------------------+
|
v
+-------------------+
| Connect WiFi |
+-------------------+
|
v
+-------------------+
| Wait for Button |
+-------------------+
|
v
+-------------------+
| Detect Press Type |
+-------------------+
| | |
| | |
v v v
Single Double Long
Press Press Press
| | |
v v v
Trigger Trigger Trigger
URL 1 URL 2 URL 3
| | |
+-------+-------+
|
v
+-------------------+
| Send ntfy Status |
+-------------------+
This project works with:
- n8n
- Home Assistant
- ntfy
- Tasker APIs
- Node-RED
- Custom webhook APIs
- REST APIs
- Local network automation
Update:
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASSWORD = "YOUR_PASSWORD";const char* WEBHOOK_URL =
"https://your-webhook-url";const char* WEBHOOK_SINGLE =
"https://your-single-url";
const char* WEBHOOK_DOUBLE =
"https://your-double-url";
const char* WEBHOOK_LONG =
"https://your-long-url";Supports success and failure alerts.
Example:
const char* NTFY_URL =
"https://your-ntfy-topic";Notifications include:
- Success triggers
- HTTP failures
- WiFi disconnects
- Webhook errors
This project is optimized for:
- Low CPU usage
- Stable WiFi reconnect
- Safe HTTP cleanup
- Low idle power usage
- Continuous home operation
Techniques used:
millis()based timing- Debounce protection
- Cooldown protection
- HTTPS timeout handling
- Non-blocking logic
Best suited for:
- Home automation
- Personal productivity
- Smart room triggers
- Automation shortcuts
- IoT experiments
- Physical webhook triggers
- Toggle lights
- Trigger n8n workflow
- Send Telegram notification
- Trigger alternate automation
- Start media mode
- Enable focus mode
- Emergency alert
- Shutdown workflow
- Panic notification
- Home security action
Arduino IDE:
- File
- Preferences
- Additional Boards URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then:
- Boards Manager
- Install ESP32
Built-in ESP32 libraries:
#include <WiFi.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>No extra libraries required.
- Connect ESP32
- Select ESP32 board
- Select COM port
- Upload code
- Open Serial Monitor
- Baud rate:
115200
[WiFi] Connected
[Button] Single Press
[Single Press] HTTP Code: 200
[System] Single Press Success
Demo at: https://youtube.com/shorts/wLUjxjM3vpE?si=yuezYIr6ZCef1Q6i
MIT License



