Smart doorbell with ESP32-CAM + Telegram instant photo alerts

Asked 1 week ago Modified 3 days ago Viewed 12 times
Smart doorbell with ESP32-CAM + Telegram instant photo alerts

What it does: when someone presses the doorbell (or motion is detected), it snaps a photo and pushes it straight to my phone via a Telegram bot. Been running 3 months without a reboot.

Parts list

  • ESP32-CAM with OV2640 module
  • HW-104 USB-to-serial programmer for ESP32-CAM (or an FTDI module)
  • HC-SR501 PIR motion sensor (3.3V version)
  • 1 × momentary push button (the actual bell)
  • 1 × 10kΩ pull-up resistor for the button
  • Small 5V/2A power supply + a USB cable cut to length
  • 3D-printed enclosure with a lens cutout (link in comments)

Creating the Telegram bot

1. Open Telegram, search for @BotFather, send /newbot.
2. Give it a name and username. BotFather returns a token — save it.
3. Send your bot a 'hi' message from your own account, then visit https://api.telegram.org/bot<TOKEN>/getUpdates and find your `chat_id` in the JSON.

Wiring

  • PIR OUT → GPIO13
  • Button → GPIO12 with pull-up to 3.3V, other side to GND
  • 5V from power supply → 5V on ESP32-CAM (NOT 3.3V — the cam module is hungry)
  • GND common everywhere

Sketch outline

1. In setup(), init the camera (use the AI-Thinker pinout), connect to Wi-Fi, init Telegram with the UniversalTelegramBot library.
2. In loop(), poll GPIO12 and GPIO13. On any trigger, call esp_camera_fb_get() and send the resulting JPEG with bot.sendPhotoByBinary().
3. Debounce both inputs — I use a 500ms cooldown.

Tips from 3 months of use

  • The PIR has two pots — sensitivity and hold time. Set hold time to its minimum so consecutive triggers don't merge.
  • Mount the camera under an eave so direct sunlight doesn't bleach the sensor.
  • Add a TTL-level external watchdog (or just `esp_task_wdt_init`) — the ESP32-CAM occasionally hangs and a reboot every 24h is healthy.
  • Wi-Fi reliability is everything. If your front door is far from the router, add an external antenna to the cam module — it has a U.FL connector for exactly this.