Projects / One-press Wi-Fi button

One-press Wi-Fi button

Beginner1 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP3214.7 mA

    Wire the board

    Button between GPIO 3 and ground, LED on GPIO 4, LiPo to the 5V pin and ground.

  2. ESP32

    Set up the hook

    Make a web hook that does what you want, such as adding a row or sending a message.

  3. ESP32

    Edit the sketch

    Add your Wi-Fi details and the hook URL.

  4. ESP32

    Upload

    Select ESP32C3 Dev Module and the right port.

  5. ESP3214.8 mA

    Press the button

    After a second or two the green LED flashes and the hook fires.

  6. ESP32

    Measure the wake time

    From press to flash, and check it stays under 3 seconds.

  7. ESP32

    Check sleep

    A USB meter or a multimeter in series shows the current falling when it sleeps.

In short

How do you build a one-press Wi-Fi button?

A battery button wakes, connects, fires a web hook to log an event, and sleeps again. You need ESP32-C3 SuperMini, Tactile push button 6 mm, Li-Po battery 3.7 V 500 mAh, LED 5 mm green, Resistor 220 Ω and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
ButtonESP32-C3 GPIO 3 and GNDPress to wake (wakes from deep sleep on a low level)
Green LED anodeGPIO 4 through 220 ΩSuccess flash
Green LED cathodeGNDReturn
LiPo battery +ESP32-C3 5V pinBattery power (the board's regulator runs from about 3.6 to 5.5 V)
LiPo battery -GNDCommon ground

Code

Arduino IDE with the ESP32 board package by Espressif, board "ESP32 Dev Module". Choose ESP32C3 Dev Module. Any web hook that accepts a GET works, such as IFTTT Webhooks or your own service. The hook address often contains a secret key, so do not publish it. A bare ESP32-C3 supermini draws a few hundred microamps in deep sleep, but its power LED draws more, so remove the LED for long battery life.

Runs on a virtual ESP32-C3 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <WiFi.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
#include "driver/gpio.h"

const char *SSID = "your-wifi", *PASSWORD = "your-password";
const char *HOOK_URL = "https://example.com/your-webhook";     // your web hook address; treat it as a secret
const byte BTN = 3, LED = 4;

void sleepNow() {
  gpio_pullup_en((gpio_num_t)BTN);                          // keep the pull-up on during sleep
  gpio_pulldown_dis((gpio_num_t)BTN);
  esp_deep_sleep_enable_gpio_wakeup(1ULL << BTN, ESP_GPIO_WAKEUP_GPIO_LOW);
  esp_deep_sleep_start();
}

void setup() {
  pinMode(LED, OUTPUT);
  unsigned long start = millis();
  WiFi.mode(WIFI_STA);
  WiFi.begin(SSID, PASSWORD);
  while (WiFi.status() != WL_CONNECTED && millis() - start < 8000) delay(50);
  if (WiFi.status() == WL_CONNECTED) {
    WiFiClientSecure client; client.setInsecure();               // skips certificate checks: fine for a toy
    HTTPClient http;
    http.begin(client, HOOK_URL);
    int code = http.GET();
    http.end();
    if (code > 0 && code < 400) { digitalWrite(LED, HIGH); delay(500); digitalWrite(LED, LOW); }
  }
  while (digitalRead(BTN) == LOW) delay(10);                     // wait for release so it does not wake again at once
  sleepNow();
}

void loop() {}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Press the buttonHook fires and LED flashes
Wake to flash timeUnder 3 seconds on a good network
IdleDraws far less than 1 mA
Hold the buttonDoes not fire again until released and pressed

If it does not work

Never wakes

The wake pin must be an RTC-capable pin on the C3: GPIO 0 to 5. Check it is GPIO 3.

Wakes by itself

The pin is floating. Add a 100 kΩ pull-up resistor.

Fails to connect

Weak Wi-Fi. Move closer or increase the timeout.

Battery drains quickly

Board LED and regulator draw current. Use a low-quiescent regulator.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the one-press Wi-Fi button?

ESP32-C3 SuperMini, Tactile push button 6 mm, Li-Po battery 3.7 V 500 mAh, LED 5 mm green, Resistor 220 Ω and Jumper wires male to male (40 pcs, 20 cm).

How long does the one-press Wi-Fi button take to build?

About 60 minutes for a beginner maker, in 7 steps.

How do I know the one-press Wi-Fi button works?

Press the button: Hook fires and LED flashes. Wake to flash time: Under 3 seconds on a good network. Idle: Draws far less than 1 mA.

Never wakes: what should I check?

The wake pin must be an RTC-capable pin on the C3: GPIO 0 to 5. Check it is GPIO 3.

Wakes by itself: what should I check?

The pin is floating. Add a 100 kΩ pull-up resistor.

Fails to connect: what should I check?

Weak Wi-Fi. Move closer or increase the timeout.

Battery drains quickly: what should I check?

Board LED and regulator draw current. Use a low-quiescent regulator.