A smart home security system with PIR, camera, and siren for India provides 24/7 protection tailored to Indian threat scenarios: unauthorised entry, domestic help monitoring, package theft, and terrace intrusion. This complete DIY project uses ESP32-CAM for video capture, HC-SR501 PIR for motion detection, and an ESP8266 controller that sends instant Telegram photo alerts and activates a 12V siren, all for under Rs 2,500 total.
Table of Contents
- Indian Home Security Threat Model
- Hardware: ESP32-CAM, PIR, Siren, and Power
- ESP32-CAM Setup and Photo Capture
- PIR Motion Detection and Zones
- Telegram Bot Alerts with Photo Snapshots
- Siren and Strobe Light Integration
- Home Assistant Integration for Armed/Disarmed Modes
- Frequently Asked Questions
Indian Home Security Threat Model
Indian homes face specific security challenges:
- Domestic help monitoring: Alert when domestic helper arrives/departs during defined hours
- Terrace and balcony access: Common break-in points in Indian apartment buildings
- Package theft: Doorstep delivery theft increased significantly after e-commerce growth
- After-dark garden/compound intrusion: Especially relevant in independent houses and farm properties
- False alarms: Pets (common in Indian homes), cleaning staff, family members – smart detection zones prevent nuisance alerts
Recommended: UNO WiFi R3 (ATmega328P + ESP8266)
Use the UNO WiFi R3 as your security system hub node. Its ESP8266 handles Telegram alert sending and MQTT integration while the ATmega328P manages multiple PIR zones and siren control.
Hardware: ESP32-CAM, PIR, Siren, and Power
Complete BOM with India prices (2025):
- ESP32-CAM (AI Thinker) with OV2640 camera: Rs 320 per unit
- HC-SR501 PIR sensor: Rs 60 per zone (buy 4-6 for a 2BHK)
- 12V 6-tone siren: Rs 150 (automotive type, available on Amazon India)
- 12V strobe light: Rs 120 (adds visual deterrent)
- 5V 3A USB adapter: Rs 200 (powers ESP32-CAM and ESP8266 hub)
- 12V 2A adapter: Rs 180 (for siren/strobe)
- 2N2222 transistor + 1N4007 flyback diode: Rs 10 (for siren drive)
- Total BOM for 3-camera + 4-PIR system: approximately Rs 2,200
ESP32-CAM Setup and Photo Capture
#include <Arduino.h>
#include "esp_camera.h"
#include <WiFi.h>
// AI Thinker ESP32-CAM pin definitions
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
// ... (full pin list from Espressif docs)
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_VGA; // 640x480
config.jpeg_quality = 12; // 0-63, lower=better quality
config.fb_count = 1;
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed: 0x%x", err);
return;
}
// Capture a frame
camera_fb_t* fb = esp_camera_fb_get();
if (!fb) return; // capture failed
// fb->buf contains JPEG data, fb->len is size
esp_camera_fb_return(fb);
PIR Motion Detection and Zones
// HC-SR501 sensitivity: turn trimmer CW for longer range (up to 7m)
// Delay trimmer: set to minimum (2-3 seconds) for fastest re-trigger
#define PIR_DOOR GPIO_NUM_13 // Front door zone
#define PIR_BALCONY GPIO_NUM_14 // Balcony zone
#define PIR_TERRACE GPIO_NUM_15 // Terrace zone
#define PIR_KITCHEN GPIO_NUM_16 // Kitchen/back door zone
// Interrupt-driven for fast response
void IRAM_ATTR pirISR_door() {
if (!armState) return; // system disarmed
pirTriggered = ZONE_DOOR;
xSemaphoreGiveFromISR(alertSemaphore, NULL);
}
void setup() {
attachInterrupt(PIR_DOOR, pirISR_door, RISING);
attachInterrupt(PIR_BALCONY, pirISR_balcony, RISING);
}
Add a 30-second cool-down per zone to prevent alert flooding. After initial detection and photo capture, wait 30 seconds before allowing the same zone to re-trigger.
Recommended: Mega WiFi R3 (ATmega2560 + ESP8266)
The Mega WiFi R3 with 54 I/O pins is ideal for large Indian homes or farmhouses. Connect up to 20 PIR zones, 4 cameras, and 8 relay-controlled sirens and lights from a single controller board.
Telegram Bot Alerts with Photo Snapshots
Create a Telegram bot via @BotFather and get your bot token and chat ID.
#include <UniversalTelegramBot.h>
#include <WiFiClientSecure.h>
#define BOT_TOKEN "YOUR_BOT_TOKEN"
#define CHAT_ID "YOUR_CHAT_ID" // get from @userinfobot
WiFiClientSecure client;
UniversalTelegramBot bot(BOT_TOKEN, client);
void sendSecurityAlert(const char* zone, camera_fb_t* fb) {
String msg = "ALERT: Motion in " + String(zone) + "n";
msg += "Time (IST): " + getISTTime() + "n";
msg += "System: ARMED";
// Send text alert first (fast)
bot.sendMessage(CHAT_ID, msg, "");
// Send photo (uses multipart form upload)
bot.sendPhoto(CHAT_ID, fb->buf, fb->len, "image/jpeg");
}
The Telegram bot delivers alerts to your phone even when you have no data connection via WiFi calling – SMS fallback ensures you are always notified.
Siren and Strobe Light Integration
// Siren drive via 2N2222 NPN transistor
// ESP32 GPIO can only sink/source 40mA; 12V siren needs transistor switch
void activateSiren(int durationSeconds) {
digitalWrite(SIREN_PIN, HIGH); // turn on siren via transistor
digitalWrite(STROBE_PIN, HIGH); // visual deterrent
delay(durationSeconds * 1000);
// Ensure auto-off even if MQTT disable command missed
digitalWrite(SIREN_PIN, LOW);
digitalWrite(STROBE_PIN, LOW);
}
// MQTT to silence: subscribe to home/security/siren/set
void mqttCallback(char* topic, byte* payload, unsigned int length) {
if (strcmp(topic, "home/security/siren/set") == 0) {
if (strncmp((char*)payload, "OFF", 3) == 0)
digitalWrite(SIREN_PIN, LOW);
}
}
Home Assistant Integration for Armed/Disarmed Modes
Add an alarm panel in Home Assistant:
# configuration.yaml
alarm_control_panel:
- platform: manual
name: Home Security
arming_time: 30 # 30 sec grace period after arming
delay_time: 20 # 20 sec grace period on entry before alarm
trigger_time: 120 # siren runs for 2 minutes
armed_home:
disarmed_state_triggers:
- 'disarmed'
armed_away:
disarmed_state_triggers:
- 'disarmed'
Use HA automations to: arm when everyone leaves (device tracker shows all phones away from home), disarm when family member’s phone returns, and escalate to SMS/phone call if siren runs >60 seconds without disarm.
Recommended: 12V 1-Channel Relay Module (RS485/Modbus)
The RS485/Modbus relay module reliably controls your security siren and strobe in electrically noisy environments. Its optocoupler isolation prevents false triggers from the high-current siren switching back into ESP32 GPIO pins.
Frequently Asked Questions
- Will the PIR sensor trigger on pets?
- Standard HC-SR501 is pet-immune if installed correctly. Mount 2.1-2.4m high, angled downward at 10-15 degrees. Dogs and cats below 25kg typically do not trigger if the PIR looks across the room rather than straight down. For guaranteed pet immunity, use a dual-technology detector (PIR + microwave) like the DSC BV-300 (Rs 1,200).
- How do I power the system during a power cut?
- Add a 12V 7Ah sealed lead-acid battery (Rs 400) with a TP4056-style 12V charging circuit. At 100mA average draw (4 cameras + PIRs), a 7Ah battery provides 70 hours of backup. The siren draw (400mA for 2 minutes) barely affects this.
- Can Telegram alerts work during mobile data outage?
- No, Telegram requires internet. Add an SMS backup: SIM800L module (Rs 280) sends SMS via a spare Jio/BSNL SIM when WiFi/internet is unavailable. Use the SIM800L’s AT+CMGS command for SMS sending.
- Is it legal to install a siren in an Indian apartment building?
- Residential societies can regulate noise-making devices under society bylaws. A 90dB indoor siren activating for 2 minutes during genuine intrusion is generally acceptable. For terrace or outdoor sirens, check with your housing society RWA. Avoid sirens above 120dB in dense urban areas (Mumbai, Delhi).
- How do I prevent false alarms from insects walking across PIR?
- Insects, spiders, and ceiling lizards (common in Indian homes) are a major PIR false alarm source. Use a tight mesh cover over the PIR Fresnel lens, or switch to microwave-PIR dual technology sensors. Software debouncing also helps: require 2 PIR pulses within 3 seconds before triggering an alert.
Add comment