Building an ESP32-CAM security camera is one of the most cost-effective ways to set up home surveillance in India. For under ₹500, you get a WiFi-enabled camera module capable of video streaming, motion detection, and even sending alerts to your phone via Telegram. This guide walks you through the complete setup from hardware assembly to software deployment.
Table of Contents
- Components Needed
- Wiring and Hardware Setup
- Flashing the Firmware
- Web Streaming Setup
- Motion Detection
- Telegram Notifications
- Power Supply Options
- Frequently Asked Questions
- Conclusion
Components Needed
The ESP32-CAM is remarkably affordable. Here is your complete shopping list:
- ESP32-CAM module: ₹350-450 — Includes the OV2640 2MP camera
- ESP32-CAM-MB programmer board: ₹100-150 — Makes uploading code via USB easy
- MicroSD card: ₹200-300 — For recording snapshots (8-32 GB is sufficient)
- USB Micro-B cable: For programming and power
- 5V power supply: Stable 5V 1A minimum for reliable operation
- 3D printed or purchased case: To weatherproof the camera for outdoor use
Total cost for a basic setup is under ₹800, making it one of the cheapest IP camera solutions available.
Wiring and Hardware Setup
If you are using the ESP32-CAM-MB programmer board, the setup is plug-and-play:
- Insert the ESP32-CAM module into the MB board, ensuring the camera faces away from the USB port
- Connect the USB cable to your computer
- The MB board handles the DTR/RTS signals for auto-programming, so no boot button pressing is needed
If programming without the MB board, use an FTDI USB-to-serial adapter:
- Connect FTDI TX to ESP32-CAM U0R (RX)
- Connect FTDI RX to ESP32-CAM U0T (TX)
- Connect FTDI GND to ESP32-CAM GND
- Connect 5V to ESP32-CAM 5V pin
- Connect GPIO0 to GND while uploading code (disconnect after upload)
Flashing the Firmware
You have two main firmware options:
Option 1: Arduino IDE CameraWebServer
- Install ESP32 board support in Arduino IDE via Boards Manager
- Open File > Examples > ESP32 > Camera > CameraWebServer
- Select your camera model (AI Thinker for most ESP32-CAM modules)
- Enter your WiFi SSID and password in the code
- Select board “AI Thinker ESP32-CAM” and upload
- Open Serial Monitor at 115200 baud to see the camera’s IP address
Option 2: ESPHome (Home Assistant Integration)
If you use Home Assistant for home automation, ESPHome provides seamless integration. Create an ESPHome YAML configuration with the camera component and flash via USB or OTA.
Web Streaming Setup
The CameraWebServer example creates a web interface accessible from any browser on your local network:
- Navigate to
http://[ESP32-IP-ADDRESS]in your browser - The interface shows a live stream with controls for resolution (from 160×120 to 1600×1200), brightness, contrast, and saturation
- Use the “Start Stream” button to begin the MJPEG video feed
- For remote access outside your home network, set up port forwarding on your router or use a service like ngrok
Stream quality depends on your WiFi signal strength. Place the ESP32-CAM within good range of your router for stable video.
Motion Detection
Add motion detection by comparing consecutive frames. The basic approach:
- Capture a reference frame periodically
- Compare each new frame against the reference using pixel-level difference calculation
- If the difference exceeds a threshold (typically 15-25% of pixels changed), trigger an alert
- Save the triggered frame to the MicroSD card with a timestamp
For more reliable motion detection, use the PIR sensor approach: connect an HC-SR501 PIR module to GPIO13. When motion is detected by the PIR, wake the camera and capture a snapshot. This method uses far less power and reduces false triggers.
Telegram Notifications
Sending camera snapshots to Telegram provides instant notifications on your phone:
- Create a Telegram bot via BotFather and note the API token
- Get your Chat ID by messaging the bot and checking the API response
- When motion is detected, capture a JPEG frame
- Use the ESP32’s HTTP client to POST the image to the Telegram Bot API
sendPhotoendpoint - You receive the photo notification instantly on your phone, no matter where you are
This approach works over any internet connection and does not require port forwarding or a static IP address.
Power Supply Options
For a reliable security camera, power supply matters:
- USB power adapter: Any stable 5V 1A or higher adapter works. Avoid cheap adapters that cause brownouts during WiFi transmission
- Solar + battery: For outdoor locations without power, a small solar panel (5W) with a LiPo battery and charge controller provides autonomous operation
- PoE splitter: If running Ethernet cable anyway, a passive PoE splitter can provide both network and power (though the ESP32-CAM itself uses WiFi)
- USB power bank: A 10,000 mAh power bank can run an ESP32-CAM for approximately 20-30 hours, useful for temporary surveillance
Frequently Asked Questions
What is the video quality of ESP32-CAM?
The OV2640 camera captures up to 1600×1200 resolution for still images and smooth video at 800×600. For security purposes, 640×480 offers the best balance of detail and frame rate.
Can I use the ESP32-CAM outdoors in Indian weather?
The bare module is not weather-resistant. Use a 3D-printed or IP-rated enclosure with silica gel packets. Avoid direct exposure to rain and extreme sun. The operating temperature range is -20 to 85 degrees Celsius.
How many cameras can I run on one network?
A typical home WiFi router handles 5-10 ESP32-CAM streams comfortably. Each camera uses about 1-3 Mbps depending on resolution and frame rate.
Is the ESP32-CAM better than a cheap IP camera?
A commercial IP camera offers better image quality and a polished app experience. The ESP32-CAM wins on customisation, privacy (no cloud dependency), and cost. It is ideal for makers who want full control over their security system.
Conclusion
The ESP32-CAM security camera project demonstrates how affordable home surveillance can be in India. For under ₹500 per camera node, you get WiFi streaming, motion detection, and Telegram alerts. Scale it to multiple rooms, add face detection using the built-in AI capabilities, or integrate with Home Assistant for a complete smart home security system.
Get your ESP32-CAM and start building from our microcontroller collection today.
Add comment