cc
cc
A PROJECT REPORT
Submitted by
N.HARISH - 8208E21EER015
S.PREM - 8208E21EER037
P.YOKESHWARAN - 8208E21EER063
of
BACHELOR OF ENGINEERING
IN
ELECTRICAL AND ELECTRONICS ENGINEERING
MAY 2025
E.G.S. PILLAY ENGINEERING COLLEGE
NAGAPATTINAM
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
ii
ACKNOWLEDGEMENT
We are very much honored and would like to profound our deep
grateful to our Academic Director Dr.S.Palani Murugan and also Head of
the Department, Dr.P.J.Suresh Babu M.E., PhD., for his expert, sincere
and valuable guidance to us. We all are must to express our sincere thanks
to our project coordinators Mr.K.Gokul Raj M,E., and Mr.B.A.Naveen
Antony M.E., for their support and motivation given to us.
We would like to express our sincere thanks to our project guide
Mr.V.Yokeswaran M.Tech., for his wide knowledge, serious research
attitude and enthusiasm in work deeply impressed and made us to complete
this project to the at most satisfaction of our superiors in a stipulated period.
We express our hearty render and thanks to all the staff members
and technical assistants of the Department of Electrical and Electronics
Engineering for their timely assistance. Our humble gratitude and thanks to
our parents and friends who have supported. Lastly to the Almighty for
showering is blessings and to many more, whom we didn’t mention here.
iii
DECLARATION
We submit the project work entitled “HOME SECURITY SYSTEM
USING ESP32 CAMERA ” E.G.S. Pillay Engineering college in
partial fulfillment of the requirements for the award of the degree of
"BACHELOR OF ENGINEERING" in ELECTRICAL AND
ELECTRONICS ENGINEERING". We declare that it was carried
out independently by us under the guidance of
Mr.V.YOKESWARAN.,M.Tech., Assistant Professor and Head in
the department of electrical and electronics engineering
N.HARISH - 8208E21EER015
S.PREM - 8208E21EER037
P.YOKESHWARAN - 8208E21EER063
SIGNATURE
Mr.V.YOKESWARAN, M.Tech,
SUPERVISOR
Assistant Professor
Department of Electrical and
Electronics Engineering
E.G.S.Pillay Engineering College
Nagapattinam
iv
ABSTRACT
v
TABLE OF CONTENTS
vi
7.1 Conclusion 44
7.2 Future work 44
7.2.1 Cloud Storage and Remote Access 44
7.2.2 Smartphone app integration 44
7.2.3 Integration with Voice Assistants 44
7.2.4 Battery Backup and Solar Power 45
7.2.5 Ai-based image processing 45
7.2.6 Multi-Camera and Multi-Sensor Setup 46
7.3 Summary 46
8 REFERENCES 47
vii
LIST OF FIGURES
viii
ABBREVIATIONS
CAM Camera
V Voltage
AO Analog Output
DO Digital Output
IR Infrared Light
RS Reed Switch
ix
CHAPTER 1
INTRODUCTION
1.1 Background of the Study
1
For a typical homeowner, such a cost is prohibitive. Many
individuals are unable to justify such an investment due to the high cost of
traditional systems, especially when they are already paying for other utilities or
financial commitments. Additionally, the installation of these systems often
requires specialized knowledge and can take several hours, requiring a
professional technician to ensure that everything is set up properly.
2
The open-source nature of the system means that it can be
adapted and integrated with other smart home devices and IoT platforms,
offering greater flexibility and scalability.
4
By making home security more intuitive and user-friendly,
the ESP32-CAM system ensures that even individuals without any technical
background can set it up and maintain it on their own.
5
CHAPTER 2
LITERATURE REVIEW
2.1 Literature Survey
6
The growing adoption of machine learning (ML) and artificial
intelligence (AI) in home security systems has brought about significant
improvements in threat detection. AI-based algorithms can analyze video
feeds for specific patterns, such as recognizing intruders or suspicious
activities. As Rai, Singh, and Choudhury (2021) demonstrate, ML can be
used to detect abnormal behavior in real-time, reducing the reliance on
human intervention and enabling automated responses to potential threats
(Rai, Singh, & Choudhury, 2021) [5].
8
Soni and Kaur (2019) highlight the importance of integrating sensors
with video surveillance in home security systems. Their research shows
how the combination of motion sensors, gas sensors, and video cameras
provides a comprehensive solution for home security. By detecting motion
or abnormal conditions, the system can trigger an alert and capture footage
for further analysis (Soni & Kaur, 2019) [18].
Sharma and Aggarwal (2021) discuss smart cameras and their role in
home security. Their work shows how the integration of IoT technologies
with smart cameras enhances the ability to monitor and control home
security systems remotely. By incorporating cloud-based video analytics,
their system can detect unusual activity and trigger alerts in real-time
(Sharma & Aggarwal, 2021) [27].
10
CHAPTER 3
METHODOLOGY
3.1 FLOW CHART
11
3.2 DESIGN OF PROPOSED SYSTEM
For Example: Fire or smoke alert. You can operate from anywhere in the
world, you just need Telegram application with Authorized bot and Internet
connectivity to your phone. Only allowed/Authorized users (who's Chat ID is
registered) will be able to interact with this Bot.
12
CHAPTER 4
SYSTEM DESIGN
Fig: 4.1
13
4.2 CIRCUIT DIAGRAM
Fig 4.2
15
CHAPTER 5
HARDWARE IMPLEMENTATION
Fig:5.1
16
The ESP32-CAM operates at 3.3V logic level but is powered by a
5V input, which is regulated onboard. It does not include a USB interface, so
programming must be done using an external USB-to-TTL (FTDI) adapter.
For uploading code, the IO0 pin needs to be pulled LOW to enable boot mode.
Once programmed, the board can operate standalone and perform various tasks
like motion detection, real-time monitoring, and data logging. The combination
of camera functionality, wireless communication, and GPIO availability makes
the ESP32-CAM a perfect fit for smart surveillance systems, especially in home
security applications. It can be used to capture images when motion is
detected, monitor doors or gas leaks, and send alerts over the internet using its
Wi-Fi capabilities. Its affordability and versatility make it a popular choice
among students, hobbyists, and engineers working on smart home and iot
projects.
Fig:5.2
17
This change is measured and converted into an output signal that can
be read by microcontrollers like ESP32, Arduino, or Raspberry Pi.The MQ6
sensor module typically provides both analog and digital outputs. The analog
output (AO) gives a continuous voltage signal proportional to the gas
concentration, while the digital output (DO) gives a HIGH or LOW signal
depending on whether the gas concentration exceeds a preset threshold
(adjustable via an onboard potentiometer).
In the context of a home security system, the MQ6 gas sensor plays
a critical role in detecting gas leaks from LPG cylinders or kitchen appliances.
Once the sensor detects a significant concentration of gas, it sends a signal to
the microcontroller, which can then trigger an alarm, send a notification to the
user, or activate other safety measures. For example, when connected to an
ESP32-CAM, the system can capture an image and send an alert through Wi-
Fi. Due to its low cost, reliability, and ease of use, the MQ6 gas sensor is a
preferred choice in many IoT-based safety systems and educational electronics
projects.
5. 3. FLAME SENSOR
Fig: 5.3
18
The Flame Sensor (IR Based) is a simple and effective electronic
module designed to detect the presence of flame or fire by sensing infrared
(IR) light emitted from a fire source. Flames emit a specific range of IR
wavelengths, and this sensor is designed to respond to IR light in the range of
760nm to 1100nm, which is typical of open flame radiation.
The Flame Sensor provides both analog and digital outputs. The
analog output gives a variable voltage that corresponds to the intensity of the IR
light detected, while the digital output provides a HIGH or LOW signal based
on whether the detected IR intensity crosses a preset threshold. This threshold
can be fine-tuned using the onboard potentiometer.
. Its detection range varies based on the flame size and ambient
lighting, but typically it can detect a flame within 0.5 to 1 meter under normal
conditions.
The Flame Sensor is highly valued for its low cost, fast response
time, and ease of integration into iot and fire safety applications, making it a
popular choice for both DIY and commercial security systems.
19
5 4. PIR MOTION SENSOR
Fig: 5.4
. The PIR (Passive Infrared) Motion Sensor – AM312 is a compact and low-
power electronic module used to detect human or animal movement by sensing changes in
infrared radiation in its environment. All living beings emit infrared radiation in the form of
body heat, and the PIR sensor is designed to detect this change when someone enters its
detection range. The AM312 is a mini version of typical PIR sensors, offering excellent
motion detection performance in a small size, making it ideal for compact embedded projects
like home security systems, automatic lighting, and alarm systems.
The AM312 PIR sensor operates with a supply voltage of 3.3V to 5V, making it
fully compatible with microcontrollers such as the ESP32, Arduino, and Raspberry Pi. It
has a digital output pin that goes HIGH (logic 1) when motion is detected and stays LOW
(logic 0) when no motion is present. The sensor has a detection range of about 3 to 5
meters and a detection angle of around 100°, which is sufficient for indoor applications. It
has an onboard control circuit and digital output, making it easy to integrate with any system
without needing complex signal processing.
In the context of a home security system, the AM312 PIR sensor is used to
monitor areas for unauthorized or suspicious movement. When connected to a
microcontroller like the ESP32-CAM, the sensor can trigger the camera to capture an image
or video, send alerts over Wi-Fi, or activate alarms. Its low current consumption and compact
form factor make it perfect for battery-powered or space-limited devices. The AM312 is
widely appreciated for its simplicity, accuracy, and cost-effectiveness, making it one of the
most popular choices for motion-sensing applications in IoT and automation systems.
20
5.5 MAGNETIC DOOR SENSORS
.
Fig: 5.5
21
5.6 MB102 POWER SUPPLY MODULE
Fig: 5.6
22
5. 7 LOGIC LEVEL SHIFTER
Fig: 5.7
23
5. 8 JUMPER WIRES (MALE-TO-MALE & MALE-TO-FEMALE)
Fig: 5.8
Fig: 5.9
25
CHAPTER 6
SOFTWARE IMPLEMENTATION
6.1 CODE
// ----------------------------------
make2explore.com----------------------------------------------------//
// Created By - [email protected]
// Version - 1.0
//
//
------------------------------------------------------------------------------------------------
-------//
26
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "esp_camera.h"
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
// Also note that you need to click "start" on a bot before it can message
you
String BOTtoken =
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
;
WiFiClientSecure clientTCP;
//
// clientTCP.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add
root certificate for api.telegram.org
27
// Adding root certificate in Setup()
//CAMERA_MODEL_AI_THINKER
#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
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#define FLASH_LED_PIN 4
// Motion Sensor
28
bool motionDetectEnable = false;
// Door Sensor
// fire sensor
String sendPhotoTelegram();
//Serial.println("MOTION DETECTED!!!");
29
motionDetected = true;
void setup(){
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
Serial.begin(115200);
pinMode(door1, INPUT);
pinMode(door2, INPUT);
pinMode(firePin, INPUT);
pinMode(smokePin, INPUT);
// Camera Flash
pinMode(FLASH_LED_PIN, OUTPUT);
digitalWrite(FLASH_LED_PIN, flashState);
// Initialize WiFi
WiFi.mode(WIFI_STA);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
clientTCP.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add
root certificate for api.telegram.org
Serial.print(".");
delay(500);
30
}
Serial.println();
Serial.println(WiFi.localIP());
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
31
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
if(psramFound()){
config.frame_size = FRAMESIZE_UXGA;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.fb_count = 1;
//config.grab_mode = CAMERA_GRAB_LATEST;
// camera init
if (err != ESP_OK) {
delay(1000);
ESP.restart();
32
// Drop down frame size for higher initial frame rate
sensor_t * s = esp_camera_sensor_get();
//err = gpio_install_isr_service(0);
if (err != ESP_OK){
if (err != ESP_OK){
delay(40000); // Give time for PIR and MQ6 Gas Sensor to get Stable
void loop(){
if (sendPhoto){
Serial.println("Preparing photo");
sendPhotoTelegram();
sendPhoto = false;
33
}
door1stat = digitalRead(door1);
Serial.println("Door1 Opened");
door1stat = true;
door2stat = digitalRead(door2);
Serial.println("Door2 Opened");
door2stat = true;
fire = digitalRead(firePin);
Serial.println("Fire Detected");
fire = false;
34
smoke = digitalRead(smokePin);
Serial.println("Smoke Detected");
smoke = false;
Serial.println("Motion Detected");
sendPhotoTelegram();
motionDetected = false;
delay(2000);
while (numNewMessages){
Serial.println("got response");
handleNewMessages(numNewMessages);
lastTimeBotRan = millis();
35
}
String sendPhotoTelegram(){
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if(!fb) {
delay(1000);
ESP.restart();
if (clientTCP.connect(myDomain, 443)) {
Serial.println("Connection successful");
clientTCP.println("Content-Type: multipart/form-data;
boundary=make2explore");
clientTCP.println();
clientTCP.print(head);
if (n+1024<fbLen) {
clientTCP.write(fbBuf, 1024);
fbBuf += 1024;
else if (fbLen%1024>0) {
clientTCP.write(fbBuf, remainder);
clientTCP.print(tail);
esp_camera_fb_return(fb);
37
long startTimer = millis();
Serial.print(".");
delay(100);
while (clientTCP.available()) {
char c = clientTCP.read();
if (c == '\n') {
if (getAll.length()==0) state=true;
getAll = "";
else if (c != '\r')
getAll += String(c);
startTimer = millis();
if (getBody.length()>0) break;
clientTCP.stop();
Serial.println(getBody);
else {
38
getBody="Connected to api.telegram.org failed.";
return getBody;
Serial.println(numNewMessages);
if (chat_id != chatId){
continue;
Serial.println(text);
if (text == "/flashOn") {
flashState = true;
39
digitalWrite(FLASH_LED_PIN, flashState);
if (text == "/flashOff") {
flashState = false;
digitalWrite(FLASH_LED_PIN, flashState);
if (text == "/photo") {
sendPhoto = true;
if (text == "/EnableMotionAlert") {
motionDetectEnable = true;
if (text == "/DisableMotionAlert") {
motionDetectEnable = false;
40
if (text == "/EnableDoorAlert") {
doorLockMonitor = true;
if (text == "/DisableDoorAlert") {
doorLockMonitor = false;
if (text == "/EnableFireAlert") {
fireDetectMonitor = true;
if (text == "/DisableFireAlert") {
fireDetectMonitor = false;
if (text == "/EnableSmokeAlert") {
smokeDetectMonitor = true;
41
bot.sendMessage(chat_id, "Smoke Detector - Enabled", "");
if (text == "/DisableSmokeAlert") {
smokeDetectMonitor = false;
if (text == "/start"){
42
welcome += "/EnableFireAlert : enables the Fire Alert System\n";
// ----------------------------------
make2explore.com----------------------------------------------------//
43
CHAPTER 7
7.1 Conclusion
While the current version of the system is effective for basic home monitoring,
there are several enhancements that can be added to improve functionality,
scalability, and user experience:
The current system stores captured images locally or transmits them over
local Wi-Fi.
44
In future versions, the system can be integrated with cloud platforms like
Google Firebase, Amazon AWS, or Thingspeak to:
o Store images and sensor logs securely.
o Provide remote access to authorized users from anywhere in the
world.
o Enable better data management and analysis over time.
Using machine learning models, the system can be made smarter by:
o Identifying human faces or animals.
o Filtering out false alarms (e.g., tree movement or shadows).
o Only sending alerts for actual threats.
45
This would make the system more accurate and reduce unnecessary
notifications.
SUMMARY
In conclusion, this project laid the foundation for a functional and affordable
smart home security system. It showcased how combining embedded
systems, IoT, and sensor networks can result in practical and scalable
solutions for real-life security challenges. With further upgrades in terms of
connectivity, intelligence, and user interface, this project can evolve into a fully
autonomous and commercial-grade home monitoring system.
46
CHAPTER 8
REFERENCES
[1] Patel, A., Shah, R., & Mehta, D. (2020). A Study on Home Security System
Using IoT. Journal of Network and Computer Applications, 129, 40-51.
Zhou, X., Li, Y., & Zhang, Q. (2018).
[2] Zhou, X., Li, Y., & Zhang, Q. (2018). Security Issues in IoT Home
Automation Systems. International Journal of Computer Science and
Security, 15(4), 174-183.
[3] Xie, L., Sun, L., & Zhang, Y. (2020). Real-Time Video Surveillance Using
ESP32-CAM. IEEE Access, 8, 3021-3031.
[4] Gorib, M. & Zawawi, M. (2018). IoT-based Home Automation Using
ESP32-CAM. International Journal of Computer Applications, 178(13), 10-
16.
[5] Li, Y., Zhou, X., & Wang, J. (2019). IoT-based Smart Security Systems for
Homes: Integration of Motion Sensors and Video Surveillance. Journal of
IoT Research, 5(2), 88-94.
[6] Sharma, R., Kumar, P., & Soni, D. (2020). Security and Privacy Concerns in
IoT-based Home Automation Systems. IEEE Internet of Things Journal,
7(7), 5431-5443.
[7] Rai, S., Singh, N., & Choudhury, S. (2021). Advanced Security Systems
Using IoT and Machine Learning. Journal of Computer Networks and
Communications, 2021, Article 334657.
[8] Zhang, Q., Wang, Z., & Liu, T. (2019). Cloud-Integrated Video
Surveillance for Home Security. Journal of Cloud Computing, 7(4), 109-
120.
[9] Kumar, R., Patel, M., & Yadav, A. (2020). Real-Time Motion Detection
Using IoT for Home Security. Journal of Embedded Systems, 21(3), 35-48.
[10] Lee, J., Kim, H., & Park, D. (2019). Low-Cost Home Security Systems
Using ESP32 and PIR Sensors. Proceedings of the 2019 IEEE International
Conference on Consumer Electronics, 123-128.
[11] Singh, M., & Kumar, V. (2021). IoT-Enabled Smart Security System with
Video Streaming. IEEE Sensors Journal, 20(11), 3152-3160.
47
[12] Wu, X., & Zhang, J. (2020). Machine Learning Integration for Real-Time
Video Surveillance. International Journal of Artificial Intelligence &
Machine Learning, 16(6), 32-41.
[13] Sharma, S., & Arora, S. (2020). Intelligent Home Security System with
ESP32 and Cloud Integration. Journal of Computer Engineering &
Applications, 26(2), 66-78.
[14] Gupta, S., & Sharma, R. (2021). IoT-Driven Smart Security Monitoring
System for Homes. International Journal of IoT and Cloud Computing,
9(1), 45-56.
[15] Yang, W., & Liu, Y. (2019). Face Recognition for Smart Home Security:
Integration with IoT. Journal of Artificial Intelligence & Robotics, 21(8),
200-213.
[16] Roy, A., & Datta, S. (2020). IoT-Based Smart Surveillance System for
Smart Homes. International Journal of Sensor Networks, 23(4), 400-412.
[17] Patel, R., & Jain, S. (2021). Cloud-Based Home Security Using IoT and
Video Analytics. Journal of Computer Vision and Applications, 10(5), 74-
85.
[18] Soni, R., & Kaur, P. (2019). IoT Solutions for Home Security Systems
with Camera and Sensors. International Journal of Advanced Computer
Science, 14(7), 450-462.
[19] Reddy, A., & Murthy, R. (2020). Smart Home Security System: IoT-Based
Remote Surveillance. International Journal of IoT Applications, 2(1), 12-
23.
[20] Raj, K., & Mishra, S. (2021). Design and Development of an IoT-Based
Home Security System with Cloud Storage. Journal of Internet of Things
and Computing, 7(3), 58-72.
[21] Yadav, R., & Saini, A. (2021). Low-Cost Video Surveillance Systems
Using IoT Technology. IEEE Transactions on Consumer Electronics, 67(4),
1234-1242.
[22] Singh, A., & Garg, P. (2020). Home Automation with ESP32-CAM: A
Cost-Effective Solution. International Journal of Automation and
Computing, 17(2), 204-217.
[23] Mehta, D., & Patel, S. (2018). Smart Home Surveillance with IoT:
Architecture and Design. Journal of Smart Systems, 5(2), 99-109.
[24] Iqbal, M., & Hussain, A. (2021). IoT-Based Home Security Systems: A
Survey. International Journal of Engineering and Technology, 13(2), 204-
213.
48
[25] Kumar, M., & Nair, R. (2020). IoT-Enabled Smart Video Surveillance
System. Journal of Internet of Things and Smart Applications, 6(4), 212-
221.
[26] Patil, P., & Jain, A. (2019). Real-Time Monitoring of Home Security Using
ESP32-CAM. IEEE Internet of Things Journal, 6(10), 1230-1240.
[27] Sharma, A., & Aggarwal, R. (2021). Home Security System Using Smart
Cameras. Journal of Communication Networks, 12(6), 87-99.
[28] Tiwari, A., & Kumar, R. (2020). IoT-Based Home Automation and
Security System with ESP32. International Journal of IoT and Security,
10(1), 12-25.
[29] Patil, S., & Singh, V. (2020). Video Surveillance and IoT Integration for
Home Security Systems. International Journal of Electronics and
Communication, 45(3), 44-56.
[30] Mehta, P., & Kumar, S. (2021). IoT-Based Home Surveillance System
Using ESP32-CAM and Cloud Integration. Journal of Digital Innovations,
19(7), 221-234.
49