Advanced
5 hours
ESP32 Doorbell with Telegram Notification and Camera Snapshot
This smart doorbell uses the ESP32-CAM module — a tiny ESP32 with an onboard OV2640 camera — to take a photo when a doorbell button is pressed and immediately send it to your Telegram account via the Bot API. You receive a photo notification on your phone within 2–3 seconds regardless of where you are in the world. No subscription, no cloud service account, no monthly fee.
What You’ll Need
- ESP32-CAM module (AI-Thinker variant)
- FTDI USB-to-serial adapter (for initial programming — ESP32-CAM has no USB)
- Momentary push button (doorbell button)
- LED indicator light (optional)
- 5 V / 2 A power supply (ESP32-CAM and camera draw significant current at startup)
- Telegram account and Telegram app
- Weatherproof enclosure
Step-by-Step Instructions
- Create a Telegram bot: Open Telegram, search for @BotFather. Send /newbot, choose a name and username. Save the bot token. Message your bot once, then visit api.telegram.org/bot[TOKEN]/getUpdates to get your chat_id.
- Wire for programming: FTDI TX → ESP32-CAM RX (U0R). FTDI RX → ESP32-CAM TX (U0T). FTDI GND → GND. FTDI 5 V → 5 V. Bridge GPIO0 to GND for flash mode.
- Wire the button: Button between GPIO 13 and GND. GPIO 13 set as INPUT_PULLUP. (Use a pin not needed by the camera module.)
- Write the sketch: On button press, init the camera, capture a JPEG frame, connect to WiFi, POST the image to the Telegram sendPhoto endpoint using a multipart/form-data request with UniversalTelegramBot library. Send a text message first (faster) then the photo.
- Handle flash: The onboard LED flash (GPIO 4) can be briefly activated before capture for night-time snapshots.
- Power optimisation: Use light sleep between doorbell presses — wake on GPIO 13 interrupt. Reduces idle current from ~180 mA to ~10 mA.
- Weatherproof: Mount in a suitable outdoor box. Use cable gland for wire entry. Apply silicone around the camera lens hole.
Safety Notes
- Any internet-connected camera is a potential privacy risk — never point it where it can capture areas beyond your property boundary.
- Store WiFi credentials using the Preferences library, not hardcoded in source code you might share.
Tips & Troubleshooting
- Camera init failure (error -1) is almost always a power issue — the ESP32-CAM needs a solid 5 V / 2 A supply; USB chargers below this spec will cause random failures.
- Blurry images: remove the lens protector film from the OV2640 (easy to miss from factory).
- Add a motion detection trigger using PIR sensor on GPIO 12 so you get a photo even without someone pressing the button.