ESP32 Doorbell: Phone Alerts, Deep Sleep and ESP32-CAM Version
Build an ESP32 doorbell: press the button, the buzzer sounds and your phone gets an instant alert. Deep sleep for months on a battery, wake pins and ESP32-CAM.
An ESP32 doorbell is a smart bell that sounds a buzzer when the button is pressed and sends an instant notification to your phone over Wi-Fi. Even when you're out, you know who came to the door and when, while the chime still rings at the door as usual. The bell you build in this article spends almost all of its time in deep sleep and only wakes up when someone presses the button, so a single 18650 cell can keep it running for months.
You'll see three versions: a battery bell that messages you on Telegram, an ntfy version that does the same job with a single HTTP request, and an ESP32-CAM version that photographs whoever rang. You'll also learn which pins can wake the ESP32, how much current each stage draws, how to calculate battery life and how to connect safely in parallel with your existing bell.

How does an ESP32 doorbell work?
The bell lives in a loop. While the ESP32 is in deep sleep, the CPU, Wi-Fi and most of the memory are off; only the RTC controller stays awake and watches the wake pin. When the button is pressed, the pin goes LOW, the ESP32 wakes up and runs the program from the start: first the buzzer sounds, then it joins Wi-Fi, sends the notification with an encrypted (HTTPS) request and goes back to sleep. The whole job usually takes 3 to 6 seconds. The currents below are approximate values for the bare ESP32 module; a development board's regulator and LED add to them.
| Stage | Duration | Approximate current |
|---|---|---|
| Deep sleep (ext0 wake-up enabled) | Until the button is pressed | 10–20 µA (bare module) |
| Boot and buzzer | 0.5–1 s | 40–70 mA (buzzer included) |
| Wi-Fi connection (with DHCP) | 1–3 s | 100–150 mA average, peaks of 250 mA and more |
| Notification over HTTPS | 1–2 s | 100–150 mA |
| Back to sleep | 0.2 s | 30–50 mA |
Parts list
- ESP32 board: Any ESP32 DevKit is fine for testing. For the version that runs for months on a battery, use a board with a low-current regulator or a bare ESP32 module.
- Push button: If it goes outdoors, choose a waterproof doorbell button; the contact inside works the same way.
- Active buzzer and driver: a 3.3–5 V active buzzer, an NPN transistor (BC547 or 2N2222) and a 1 kΩ base resistor.
- Power: an 18650 Li-ion cell, a holder, a TP4056 charger module and a 3.3 V LDO regulator that supplies at least 500 mA with a quiescent current of a few microamps.
- If you connect to the old bell: a PC817 optocoupler, a 1 kΩ resistor and a 1N4148 diode.
- For the photo version: an AI-Thinker ESP32-CAM, a USB-TTL adapter for programming and a 5 V 2 A power supply.
Wake-up pin: which pins can wake the ESP32?
In deep sleep only the pins called RTC GPIOs can be watched; a button on GPIO 5, 16, 17, 18, 19, 21, 22 or 23 will never wake the ESP32. In this article we use the ext0 method, which watches the level of a single pin: the button goes between GPIO 33 and GND, and we enable the internal pull-up that stays on during sleep. You can see your board's pin map in the Pinout tool.
| Wake-up method | Usable pins | Use in a doorbell |
|---|---|---|
| ext0 (one pin, level) | RTC GPIO: 0, 2, 4, 12–15, 25–27, 32–39 | Single-button bell; the method in this article |
| ext1 (several pins) | The same RTC pins | Two buttons for front and back door; the classic ESP32 only offers "all LOW" or "any HIGH" |
| Timer | No pin needed | Report the battery voltage once a day |
| Touch | T0–T9 (GPIO 4, 0, 2, 15, 13, 12, 14, 27, 33, 32) | A bell that rings when you touch a metal plate |
| ext0 on GPIO 34–39 | Input-only pins | No internal pull-up; a 100 kΩ external resistor is required |
Wiring
| Part | ESP32 connection | Note |
|---|---|---|
| Button (leg 1) | GPIO 33 | Internal pull-up on in sleep, LOW when pressed |
| Button (leg 2) | GND | No extra resistor needed |
| Transistor base | GPIO 25 through 1 kΩ | HIGH makes the buzzer sound |
| Transistor emitter | GND | NPN, low-side switch |
| Buzzer (+) | 5V (VIN) or 3V3 | Depending on the buzzer's rated voltage |
| Buzzer (−) | Transistor collector | The transistor connects the buzzer to GND |
| Battery + LDO output | 3V3 pin | Unplug USB while running on the battery |
Step by step: the battery-powered Telegram doorbell
- In Telegram, create a new bot with BotFather and copy the token it gives you. We show how to create a bot and find your own chat ID step by step in ESP32 Telegram Bot.
- Install the UniversalTelegramBot and ArduinoJson libraries from the Arduino IDE Library Manager.
- Replace the Wi-Fi name, password, token and chat ID in the code with your own. Never share the token; anyone who has it can control the bot.
- Upload the code and open the Serial Monitor at 115200 baud. On first boot the board immediately prints "Derin uyku" (deep sleep) and goes to sleep.
- Press the button: the buzzer beeps twice, the onboard LED lights up and within a few seconds your phone receives a "Someone is at the door!" message.
- Once everything works, unplug the USB cable, power the circuit from the battery and LDO, and repeat the test.
1// ESP32 Wi-Fi kapı zili: butonla uyan, buzzer çal, Telegram'a bildir, yeniden uyu
2// ESP32 Wi-Fi doorbell: wake on the button, beep, notify on Telegram, sleep again
3#include <WiFi.h>
4#include <WiFiClientSecure.h>
5#include <UniversalTelegramBot.h>
6#include <ArduinoJson.h>
7#include <time.h>
8#include "driver/rtc_io.h"
9
10const char* WIFI_SSID = "AgAdi"; // Wi-Fi adın (yalnız 2,4 GHz) / your Wi-Fi name (2.4 GHz only)
11const char* WIFI_PASS = "Sifre123"; // Wi-Fi şifren / your Wi-Fi password
12#define BOT_TOKEN "BOT_TOKENINI_BURAYA_YAZ" // BotFather'ın verdiği token / token from BotFather
13#define CHAT_ID "CHAT_ID_BURAYA" // bildirimin gideceği ID / the ID that gets the alert
14
15const gpio_num_t BUTON_PIN = GPIO_NUM_33; // RTC pini, buton GND'ye / RTC pin, button to GND
16const int BUZZER_PIN = 25; // transistör üzerinden aktif buzzer / active buzzer via a transistor
17const int LED_PIN = 2; // dahili LED: "gönderiyorum" / onboard LED: "sending"
18const unsigned long WIFI_SURE = 10000; // Wi-Fi için en fazla 10 sn / at most 10 s for Wi-Fi
19const time_t BEKLEME_SN = 20; // 20 sn içinde ikinci bildirim yok / no second alert within 20 s
20
21RTC_DATA_ATTR uint32_t zilSayisi = 0; // derin uykuda silinmez / survives deep sleep
22RTC_DATA_ATTR time_t sonBildirim = -1000; // son bildirimin zamanı / time of the last alert
23
24WiFiClientSecure client;
25UniversalTelegramBot bot(BOT_TOKEN, client);
26
27void zilCal() {
28 for (int i = 0; i < 2; i++) { // iki kısa öttürme: "ding-dong" / two short beeps: "ding-dong"
29 digitalWrite(BUZZER_PIN, HIGH);
30 delay(200);
31 digitalWrite(BUZZER_PIN, LOW);
32 delay(150);
33 }
34}
35
36bool wifiBaglan() {
37 WiFi.mode(WIFI_STA);
38 WiFi.begin(WIFI_SSID, WIFI_PASS);
39 unsigned long bas = millis();
40 while (WiFi.status() != WL_CONNECTED) {
41 if (millis() - bas > WIFI_SURE) return false; // pili boşa harcama / don't waste the battery
42 delay(100);
43 }
44 return true;
45}
46
47void uyu() {
48 // Buton 200 ms boyunca bırakılmış olmalı, yoksa hemen yeniden uyanırız
49 // The button must be released for 200 ms, otherwise we would wake up again at once
50 unsigned long serbest = millis();
51 while (millis() - serbest < 200) {
52 if (digitalRead(BUTON_PIN) == LOW) serbest = millis();
53 delay(5);
54 }
55 WiFi.disconnect(true);
56 WiFi.mode(WIFI_OFF);
57 rtc_gpio_pullup_en(BUTON_PIN); // iç pull-up uykuda da açık / internal pull-up stays on in sleep
58 rtc_gpio_pulldown_dis(BUTON_PIN);
59 esp_sleep_enable_ext0_wakeup(BUTON_PIN, 0); // pin LOW olunca uyan / wake when the pin goes LOW
60 Serial.println("Derin uyku / deep sleep");
61 Serial.flush();
62 esp_deep_sleep_start();
63}
64
65void setup() {
66 rtc_gpio_deinit(BUTON_PIN); // pini yeniden normal GPIO yap / make it a normal GPIO again
67 pinMode(BUTON_PIN, INPUT_PULLUP);
68 pinMode(BUZZER_PIN, OUTPUT);
69 pinMode(LED_PIN, OUTPUT);
70 Serial.begin(115200);
71
72 if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_EXT0) {
73 zilCal(); // önce ses, Wi-Fi'yi bekleme / sound first, don't wait for Wi-Fi
74 zilSayisi++;
75 time_t simdi = time(nullptr); // RTC saati uykuda da işler / the RTC clock keeps running in sleep
76 if (simdi - sonBildirim >= BEKLEME_SN) {
77 digitalWrite(LED_PIN, HIGH);
78 if (wifiBaglan()) {
79 client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // api.telegram.org kök sertifikası / root certificate
80 String mesaj = "Kapı çalıyor! / Someone is at the door! #" + String(zilSayisi);
81 bool tamam = bot.sendMessage(CHAT_ID, mesaj);
82 Serial.println(tamam ? "Gonderildi / sent" : "Gonderilemedi / failed");
83 if (tamam) sonBildirim = simdi;
84 } else {
85 Serial.println("Wi-Fi yok / no Wi-Fi");
86 }
87 digitalWrite(LED_PIN, LOW);
88 }
89 } else {
90 Serial.println("Ilk acilis / first boot"); // pil takıldı ya da reset / battery inserted or reset
91 }
92 uyu();
93}
94
95void loop() {
96 // Buraya hiç gelinmez: her uyanış setup() ile başlar
97 // Never reached: every wake-up starts again in setup()
98}An ESP32 that wakes from deep sleep restarts the program from the beginning and never reaches loop(), so all the work happens in setup(). The code first checks the wake-up cause: if it's ext0, it sounds the buzzer without waiting for Wi-Fi, because the person at the door should hear it right away. After the notification, the uyu() function waits until the button has been released for 200 ms; if the board went to sleep while the button was still held, it would wake up instantly and flood you with messages. The key lines:
| Code | What does it do? |
|---|---|
| esp_sleep_enable_ext0_wakeup(BUTON_PIN, 0) | Sets the board to wake when GPIO 33 goes LOW |
| rtc_gpio_pullup_en(BUTON_PIN) | Keeps the internal pull-up resistor on during sleep |
| rtc_gpio_deinit(BUTON_PIN) | Turns the pin back into a normal GPIO after waking, so digitalRead works |
| RTC_DATA_ATTR | Keeps a variable in the 8 KB RTC memory that survives sleep |
| time(nullptr) | The RTC clock keeps running in sleep; the 20-second cooldown is based on it |
| WIFI_SURE | Gives up after 10 seconds if the router is off, so the battery isn't wasted |
Battery life: months of standby with deep sleep
Two things decide battery life: the current in sleep and the energy used on each ring. If the board draws an average of 150 mA during 5 seconds awake, one ring costs 150 × 5 / 3600 = 0.21 mAh. Ten rings a day add up to 2.1 mAh. The real difference shows up in sleep: on a typical DevKit, the AMS1117 regulator and the power LED draw about 5 mA even in sleep, which is 120 mAh a day. With a bare module and an LDO with a very low quiescent current, sleep current drops to about 25 µA and only 0.6 mAh a day is used. To run the numbers with your own values, use the battery life calculator.
| Circuit | Sleep current | Daily consumption | With a 2500 mAh 18650 |
|---|---|---|---|
| Typical ESP32 DevKit, 10 rings a day | About 5 mA | About 122 mAh | About 20 days |
| Bare module + low-current LDO, 10 rings a day | About 25 µA | About 2.7 mAh | Over 2 years on paper, about 1 year in practice |
| Bare module + low-current LDO, 50 rings a day | About 25 µA | About 11 mAh | About 7 months |
The 2 years on paper will be shorter in real life, because a Li-ion cell slowly discharges by itself even when unused, and its capacity drops in cold weather. Still, standby of around a year is more than enough for a doorbell. You'll find all the details on deep sleep, RTC memory and the other wake-up methods in ESP32 Deep Sleep.
Connecting in parallel with an existing bell
If you want the ESP32 to alert you without replacing your current bell button, first find out what voltage the bell runs on. If there is a bell transformer supplying 8–12 V AC, as in most homes in Germany, you can connect a PC817 optocoupler across the button: the optocoupler's LED gets a 1 kΩ series resistor and a 1N4148 diode in reverse parallel, and the output transistor goes between GPIO 33 and GND. The bell voltage never touches the ESP32; the only link between the two sides is light.
| Bell system | How to connect the ESP32 | Note |
|---|---|---|
| Low-voltage AC (8–12 V transformer) | PC817 optocoupler in parallel with the button | On AC the LED flashes 50 times a second; the code's 200 ms release wait counts it as one press |
| Low-voltage DC (battery bell) | PC817 or a second contact on the button | Mind the polarity |
| 230 V mains bell | Don't connect it | Build the ESP32 bell separately or ask an electrician |
| Intercoms and video door systems | Don't connect it | The line may carry digital data; detect the chime from outside with a sound sensor |
Photo doorbell with the ESP32-CAM
The photo version uses the AI-Thinker ESP32-CAM. When the button is pressed, the board wakes up, sounds the buzzer, starts the camera and takes a picture; then it joins Wi-Fi and sends a short message first, followed by the photo, to Telegram. Since we don't use the SD card, the button goes to GPIO 13 and the buzzer transistor to GPIO 14; GPIO 4 drives the board's white flash LED. We cover the board itself and its upload settings in ESP32-CAM.

1// ESP32-CAM fotoğraflı kapı zili: butonla uyan, fotoğraf çek, Telegram'a gönder, uyu
2// ESP32-CAM photo doorbell: wake on the button, take a photo, send it on Telegram, sleep
3#include <WiFi.h>
4#include <WiFiClientSecure.h>
5#include <UniversalTelegramBot.h>
6#include <ArduinoJson.h>
7#include "esp_camera.h"
8#include "driver/rtc_io.h"
9
10const char* WIFI_SSID = "AgAdi";
11const char* WIFI_PASS = "Sifre123";
12#define BOT_TOKEN "BOT_TOKENINI_BURAYA_YAZ"
13#define CHAT_ID "CHAT_ID_BURAYA"
14
15// AI-Thinker ESP32-CAM kamera pinleri / AI-Thinker ESP32-CAM camera pins
16#define PWDN_GPIO_NUM 32
17#define RESET_GPIO_NUM -1
18#define XCLK_GPIO_NUM 0
19#define SIOD_GPIO_NUM 26
20#define SIOC_GPIO_NUM 27
21#define Y9_GPIO_NUM 35
22#define Y8_GPIO_NUM 34
23#define Y7_GPIO_NUM 39
24#define Y6_GPIO_NUM 36
25#define Y5_GPIO_NUM 21
26#define Y4_GPIO_NUM 19
27#define Y3_GPIO_NUM 18
28#define Y2_GPIO_NUM 5
29#define VSYNC_GPIO_NUM 25
30#define HREF_GPIO_NUM 23
31#define PCLK_GPIO_NUM 22
32
33const gpio_num_t BUTON_PIN = GPIO_NUM_13; // SD kart kullanılmıyor, buton GND'ye / no SD card, button to GND
34const int BUZZER_PIN = 14; // transistör üzerinden aktif buzzer / active buzzer via a transistor
35const int FLAS_LED = 4; // beyaz flaş LED'i / white flash LED
36
37WiFiClientSecure client;
38UniversalTelegramBot bot(BOT_TOKEN, client);
39camera_fb_t *fb = nullptr; // gönderilecek kare / the frame to send
40bool veriBekliyor = false;
41bool kameraAcik = false; // kamera başlatıldı mı / was the camera started
42
43bool kameraBaslat() {
44 camera_config_t config = {};
45 config.ledc_channel = LEDC_CHANNEL_0;
46 config.ledc_timer = LEDC_TIMER_0;
47 config.pin_d0 = Y2_GPIO_NUM;
48 config.pin_d1 = Y3_GPIO_NUM;
49 config.pin_d2 = Y4_GPIO_NUM;
50 config.pin_d3 = Y5_GPIO_NUM;
51 config.pin_d4 = Y6_GPIO_NUM;
52 config.pin_d5 = Y7_GPIO_NUM;
53 config.pin_d6 = Y8_GPIO_NUM;
54 config.pin_d7 = Y9_GPIO_NUM;
55 config.pin_xclk = XCLK_GPIO_NUM;
56 config.pin_pclk = PCLK_GPIO_NUM;
57 config.pin_vsync = VSYNC_GPIO_NUM;
58 config.pin_href = HREF_GPIO_NUM;
59 config.pin_sccb_sda = SIOD_GPIO_NUM;
60 config.pin_sccb_scl = SIOC_GPIO_NUM;
61 config.pin_pwdn = PWDN_GPIO_NUM;
62 config.pin_reset = RESET_GPIO_NUM;
63 config.xclk_freq_hz = 20000000;
64 config.pixel_format = PIXFORMAT_JPEG;
65 config.frame_size = psramFound() ? FRAMESIZE_SVGA : FRAMESIZE_VGA; // 800x600 ya da 640x480 / 800x600 or 640x480
66 config.jpeg_quality = 12; // küçük = daha kaliteli / lower = better quality
67 config.fb_count = 1;
68 config.fb_location = psramFound() ? CAMERA_FB_IN_PSRAM : CAMERA_FB_IN_DRAM;
69 config.grab_mode = CAMERA_GRAB_LATEST;
70 return esp_camera_init(&config) == ESP_OK;
71}
72
73// sendPhotoByBinary geri çağırmaları: kareyi tek parça verir
74// sendPhotoByBinary callbacks: they hand over the frame in one piece
75bool veriVarMi() {
76 if (veriBekliyor) { veriBekliyor = false; return true; }
77 return false;
78}
79byte *sonrakiTampon() { return fb ? fb->buf : nullptr; }
80int tamponBoyu() { return fb ? fb->len : 0; }
81
82void uyu() {
83 unsigned long serbest = millis(); // buton 200 ms bırakılmış olsun / button released for 200 ms
84 while (millis() - serbest < 200) {
85 if (digitalRead(BUTON_PIN) == LOW) serbest = millis();
86 delay(5);
87 }
88 if (kameraAcik) esp_camera_deinit(); // kamerayı kapat / shut the camera down
89 WiFi.mode(WIFI_OFF);
90 rtc_gpio_pullup_en(BUTON_PIN);
91 rtc_gpio_pulldown_dis(BUTON_PIN);
92 esp_sleep_enable_ext0_wakeup(BUTON_PIN, 0);
93 esp_deep_sleep_start();
94}
95
96void setup() {
97 rtc_gpio_deinit(BUTON_PIN);
98 pinMode(BUTON_PIN, INPUT_PULLUP);
99 pinMode(BUZZER_PIN, OUTPUT);
100 pinMode(FLAS_LED, OUTPUT);
101 digitalWrite(FLAS_LED, LOW);
102 Serial.begin(115200);
103
104 if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_EXT0) uyu(); // ilk açılışta doğrudan uyu / sleep right away on first boot
105
106 digitalWrite(BUZZER_PIN, HIGH); // zil sesi / chime
107 delay(300);
108 digitalWrite(BUZZER_PIN, LOW);
109
110 kameraAcik = kameraBaslat();
111 if (kameraAcik) {
112 for (int i = 0; i < 3; i++) { // ilk kareler karanlık olur, at / first frames are dark, drop them
113 fb = esp_camera_fb_get();
114 if (fb) esp_camera_fb_return(fb);
115 }
116 fb = esp_camera_fb_get(); // asıl fotoğraf / the real photo
117 }
118
119 WiFi.mode(WIFI_STA);
120 WiFi.begin(WIFI_SSID, WIFI_PASS);
121 unsigned long bas = millis();
122 while (WiFi.status() != WL_CONNECTED && millis() - bas < 10000) delay(100);
123
124 if (WiFi.status() == WL_CONNECTED) {
125 client.setCACert(TELEGRAM_CERTIFICATE_ROOT);
126 bot.sendMessage(CHAT_ID, "Kapı çalıyor! / Someone is at the door!");
127 if (fb) {
128 veriBekliyor = true;
129 bot.sendPhotoByBinary(CHAT_ID, "image/jpeg", fb->len,
130 veriVarMi, nullptr, sonrakiTampon, tamponBoyu);
131 }
132 }
133 if (fb) esp_camera_fb_return(fb);
134 fb = nullptr;
135 uyu();
136}
137
138void loop() {
139}Right after the camera starts, the first few frames usually come out dark or greenish because the auto exposure hasn't settled yet, so the code throws away three frames and sends the fourth. An 800×600 resolution is sharp enough to recognise a face and small enough to send in a few seconds. One cycle, including sending the photo, takes 5–8 seconds. Because the AI-Thinker board still draws a few milliamps in deep sleep, we recommend powering this version from a 5 V adapter rather than a battery. A larger version that sends a photo on motion and responds to commands is in ESP32-CAM Telegram Photo.
Notifications with ntfy instead of Telegram
If you'd rather not set up a bot, ntfy is even simpler: you install the ntfy app on your phone, pick a topic name and subscribe to it. When the ESP32 sends a single HTTP POST request to that topic, your phone shows a notification. Topics on the free server are public; anyone who knows the topic name can read the messages, so choose a long name that's hard to guess. The code below is a stand-alone test program; you can drop the bildirimGonder() function in place of the Telegram lines in the doorbell code.
1// Telegram yerine ntfy: tek HTTP POST ile telefona bildirim
2// ntfy instead of Telegram: a phone notification with a single HTTP POST
3#include <WiFi.h>
4#include <WiFiClientSecure.h>
5#include <HTTPClient.h>
6
7const char* WIFI_SSID = "AgAdi";
8const char* WIFI_PASS = "Sifre123";
9const char* NTFY_URL = "https://ntfy.sh/KONU_ADINI_BURAYA_YAZ"; // tahmin edilmesi zor bir konu adı / a hard-to-guess topic name
10
11bool bildirimGonder(const String& mesaj) {
12 WiFiClientSecure tls;
13 tls.setInsecure(); // sertifika denetimi yok: basit ama daha az güvenli / no certificate check: simple but less secure
14 HTTPClient http;
15 if (!http.begin(tls, NTFY_URL)) return false;
16 http.addHeader("Title", "Kapi zili"); // bildirim başlığı / notification title
17 http.addHeader("Priority", "high"); // telefonda öne çıksın / make it stand out on the phone
18 int kod = http.POST(mesaj);
19 http.end();
20 Serial.printf("HTTP kodu / HTTP code: %d\n", kod);
21 return kod == 200;
22}
23
24void setup() {
25 Serial.begin(115200);
26 WiFi.mode(WIFI_STA);
27 WiFi.begin(WIFI_SSID, WIFI_PASS);
28 while (WiFi.status() != WL_CONNECTED) delay(100);
29 bildirimGonder("Kapı çalıyor! / Someone is at the door!");
30}
31
32void loop() {
33}Common mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| The ESP32 keeps waking up | The pin is floating, or it sleeps while the button is held | Check the internal pull-up lines; on GPIO 34–39 add a 100 kΩ external pull-up |
| It never wakes when the button is pressed | The button is on a pin that isn't an RTC GPIO | Use an RTC pin such as GPIO 33, 32, 27, 26, 25 or 4 |
| Sound but no message | 5 GHz Wi-Fi, wrong token or chat ID | Use a 2.4 GHz network; copy the token and ID again and check the Serial Monitor output |
| The alert takes more than 10 seconds | Weak Wi-Fi and a long DHCP wait | Set a static IP, move the router closer or use a board with an external antenna |
| The buzzer stays silent on a steady HIGH | It's a passive buzzer | Get an active buzzer or drive the passive one with PWM |
| The battery is empty within weeks | The DevKit regulator and power LED draw current in sleep | Use a low-current LDO and a bare module, and measure the current with a multimeter |
Ideas to improve the bell
- Detect someone approaching: add a PIR motion sensor so you also hear about someone waiting at the door without ringing.
- Door-opened alert: put a reed switch and a magnet on the door frame and wake from two pins with ext1.
- Second chime indoors: for a receiver that works without internet, use ESP-NOW to sound a second ESP32 inside the house.
- Smart home integration: send the ring event to MQTT and Home Assistant and switch the lights on.
- Melody chime: instead of a buzzer, play any MP3 you like with a DFPlayer Mini.
- Solar charging: keep the battery topped up outdoors with a small panel; details in the solar-powered sensor article.
A doorbell brings together the ESP32's most useful skills in one project, from button and buzzer to deep sleep and internet notifications. In the BlueGrays app you can browse related projects, from lighting an LED with a button to a motion-sensor doorbell and a Telegram alarm, each with a step-by-step circuit diagram and ready-to-use code, and extend your own bell with the parts you find there.
Frequently asked questions
How long does an ESP32 doorbell last on a battery?
It depends on the sleep current. A typical DevKit draws about 5 mA in sleep, so a 2500 mAh 18650 lasts close to three weeks. With a bare module and a low-current LDO, sleep current drops to about 25 µA, and with 10 rings a day the battery lasts close to a year.
Which pins can wake the ESP32 from deep sleep?
Only RTC GPIO pins can: 0, 2, 4, 12–15, 25–27 and 32–39. Use ext0 for a single button and ext1 for several. GPIO 34–39 have no internal pull-up, so they need an external resistor.
Does the doorbell notification need internet?
Telegram and ntfy notifications arrive over the internet, so your router must be online. If you want an alert without internet, you can send a signal with ESP-NOW to a second ESP32 inside the house and sound a buzzer there.
Can I connect an ESP32 to an existing 230 V doorbell?
Working on a 230 V line with breadboards and hobby modules is dangerous, so we don't recommend it. Building the ESP32 bell separately is the safest option. If your bell runs on an 8–12 V transformer, you can connect it in parallel with the button through a PC817 optocoupler.
Can an ESP32-CAM doorbell run on batteries?
It can, but not efficiently. The AI-Thinker ESP32-CAM's regulator and camera circuit draw a few milliamps even in deep sleep, and the current can exceed 300 mA while sending a photo. Powering the camera version from a 5 V 2 A adapter is far less trouble.
Why is my ESP32 doorbell notification delayed?
Most of the delay comes from Wi-Fi: the board reconnects to the network and gets an IP address on every wake-up. Giving the ESP32 a static IP, placing it near the router and making sure the 2.4 GHz signal is strong all shorten the time; the alert usually arrives within 3–6 seconds.
Projects to build after reading this
See all projects
ESP32 LED Control with Push Button (Push)
The LED lights up when the button is pressed and turns off when released. Shows how the ESP32's digital input pin and internal pull-up resistor are used. The INPUT_PULLUP mode eliminates the need for an external resistor.

Doorbell and Light with Motion Sensor
When someone comes up to your door, you know before they even ring. As soon as the motion sensor spots someone, the LED lights up and the buzzer plays a three-note chime from high to low; when the…

ESP32 Motion Alarm System (PIR + Buzzer + LED + Telegram)
A smart security alarm: when the PIR sensor detects motion, it sounds the buzzer, lights the LED and sends the owner an instant Telegram notification. A 30-second cooldown limits how often the alarm repeats; it does not filter out the PIR sensor's false detections. Use it at home, in a garage, a storeroom or a study.

ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)
The ESP32's Deep Sleep mode shuts down the CPU and most peripherals, cutting current draw to about 10µA, which is vital for battery-powered IoT devices. This project uses three wake-up sources: a timer (15 s), an external pin (EXT0, the button on GPIO 33) and a touch pin (T0/GPIO 4). Counters marked with RTC_DATA_ATTR survive deep sleep.

Automatic Lighting with the ESP32 PIR Motion Sensor
In this project an HC-SR501 PIR motion sensor detects someone entering the room and turns on an LED automatically. millis() tracks how long the LED stays on: each HIGH reading refreshes the last-motion time, and the LED turns off at least 10 seconds after the last HIGH. The code also waits 50 ms with delay(50) in every loop, so the loop is not fully non-blocking. Great for stairs, hallways, bathrooms or closet lighting.

ESP32 Melody Playback with Buzzer
Playing a simple melody (Twinkle Twinkle Little Star) with a passive buzzer. We play notes with tone() and noTone() functions like in Arduino - ESP32 works with the same syntax as Arduino Core 3.0+. Passive buzzer must be used (active buzzer does not play melody).

ESP32 RFID Door Lock (RC522 + Servo + OLED + Buzzer + LED)
We build a smart door lock with an ESP32, an RC522 RFID module, an SG90 servo, an SSD1306 OLED display, an active buzzer and 2 LEDs. When a card is scanned, its UID is checked against the authorized cards defined in the code; if it matches, the servo unlocks (green LED + 2 short beeps) and locks again after 5 seconds. An unknown card lights the red LED, gives 3 quick beeps and shows its UID on the OLED.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

