π‘οΈ Smart Home Security with ESP32βCAM & Telegram Bot
A DIY surveillance project that uses an ESP32βCAM, a PIR motion sensor, and a Telegram bot to create a smart, phone-controlled home security system.
Inspired by ESP32βCAM and Telegram bot integrations across the Arduino and maker community.
π§© Overview
This project transforms an ESP32βCAM into a fully functional mini security systemβno keypads, no app infractions, no hassle. Users can:
- πΈ Receive instant photos via Telegram when motion is detected.
- π«΅ Request live snapshots on demand.
- π‘ Control the onboard LED or toggle the PIR sensor.
- π Arm or disarm the motion detection remotely.
All managed through easy-to-remember Telegram bot commands. The core functionality is implemented using UniversalTelegramBot, esp_camera, and standard Arduino wiring.
π GitHub Repository
π Hackster Project
π§ Hardware Requirements
- ESP32βCAM (AIβThinker) with OV2640 camera module
- HCβSR501 PIR motion sensor, powered at 3.3β―V
- USBβtoβTTL serial adapter (e.g., PL2303)
- Jumper cables, breadboard, and power source
π§ Wiring & Setup
Connection between the Esp32Cam and the USB to serial cable
| ESP32-CAM | USB-to-Serial Cable |
|---|---|
| 5V | Red Cable |
| GPIO3 | Green Cable |
| GPIO1 | White Cable |
| GND | Black Cable |
β οΈ Connect GPIO 0 and GND ports with DuPont cable as following to load the code.
| ESP32-CAM | ESP32-CAM |
|---|---|
| GND | GPIO0 |
β οΈ Remember to disconnect the GPIO 0 and GND ports after loading the code and press the reset button on the Esp to execute the code.
Connection between Esp32Cam and PIR.
| ESP32-CAM | HC-SR501 Human Infrared Sensor |
|---|---|
| 3.3V | VCC |
| GND | GND |
| GPIO 13 | DATA |
β οΈ If ESP32 CAM takes pictures frequently or never take a picture, adjust the rotary buttons on the HC-SR501 Human Infrared Sensor.
π€ Telegram Bot Commands
Interact with the ESP via Telegram commands:
/start β Get help menu
/take_photo β Request instant snapshot
/security_on β Arm motion detection
/security_off β Disarm motion detection
/led_on β Turn onboard LED ON
/led_off β Turn onboard LED OFF
/state β Check current LED & armed state
Only messages from the authorized CHAT_ID (set in code) are processed. Others are politely ignored.
π§© Code Highlights
-
Camera & Wi-Fi initialized via
esp_camera_init()andWiFi.begin() - Motion loop: If armed and motion is detected β take photo β send via Telegram
-
Telegram handler: Parses messages using
UniversalTelegramBot, performs requested action -
Secure communication with Telegram via
WiFiClientSecure
π Ready to Get Started?
- Clone the repo and install these libraries:
-
UniversalTelegramBot,ArduinoJson,esp_camera
-
- Update the sketch:
- Set your WiFi SSID, password, Telegram BOT token, and your personal CHAT_ID
- Upload via Arduino IDE with GPIO0 bridged to GND
- Reboot and interact via Telegram!
π€ Possible Improvements
- πΎ Store photos on microSD
- π‘ Add time-based auto arming
- π§ Use face recognition for better filtering
- π Add multi-platform alerting
π Project links
If you find it useful, give it a β on GitHub! Link to repository: Github




Top comments (0)