Home Security System Using ESP32-CAM and Telegram App

by make2explore in Circuits > Electronics

14072 Views, 35 Favorites, 0 Comments

Home Security System Using ESP32-CAM and Telegram App

Home-Security-ESP32-make2explore.png

In this project we’ve build a Home Security System using ESP32-CAM Which notify us on Telegram App about any Intruder trying to break in our house by capturing and sending his photo to us. For that we’ve used motion and Door Sensors. We’ve also implemented Fire, Smoke and Gas Leak Alert system in this project.

Objectives
In this Home Security Systems project we're going to

  • Monitor Doors - (to detect any Forced/Unauthorized Entry)
  • Detect Motion - (for Intruder Alert)
  • Sense Smoke/Fire/Flame - (to detect fire in house)
  • Detect Gas leak

For this we'll use

  • Magnetic (Reed) Switch Door Sensors
  • PIR Motion Sensor Module
  • Flame/Fire Sensor Module
  • MQ-6 Liquefied Petroleum Isobutane Propane Gas Sensor module
  • Also ESP32-CAM Board has on-board camera, which we'll use to capture the Photo of Intruder.

Supplies

To build this project we'll require

  • AI Thinker ESP32-CAM Dev Board
  • Mini PIR motion sensor (AM312)
  • Magnetic (Reed/Switch) Door Sensor
  • MQ6 Gas/Smoke Sensor
  • Flame Sensor Module
  • 10k Resistors – 2 Nos
  • Logic Level Shifter Module
  • FTDI programmer (to upload code)
  • Breadboard MB102
  • MB102 Breadboard Power supply Board
  • Jumper wires
  • Battery 7.4V LiPo or Power Bank
  • USB A to Mini USB Cable (To upload the code)

Functional Block Diagram

make2explore-esp32CAM-intruder.gif
  • All sensors connected to ESP32-CAM Development board. ESP-CAM is Wi-Fi enabled so it connects to our Wireless router which is further connected to Internet.
  • To Interact with our security system and get notified about all the alerts we need to create Telegram Bot on Telegram Application in our smartphone.
  • Using this Telegram bot we can Engage/Disengage (Arm/Disarm) our Home Security System and All the alerts.
  • On Telegram app, we can also take/get live photos of our monitoring area where we have installed our ESP-CAM.
  • If all sensors and alerts enabled, then system will give alerts on telegram about whenever any security related event occurs. 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.

What Are Telegram Bots ?

make2explore-esp32-cam.gif

To Interact with our security system and get notified about all the alerts we need to create Telegram Bot on Telegram Application in our smartphone.

"Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands and inline requests. You control your bots using HTTPS requests to our Bot API."

you can check out more info about bots on Telegram Website - https://core.telegram.org/bots

Schematics

ESP32cam-Intruder-Telegram-sch.png
[Part - 1] Home Security System using ESP32 CAM and Telegram

Check out above video (Part-I) of this project, where we have explained all the above steps.

Software : Setup IDE and Boards

How to Install ESP8266 & ESP32 Dev Boards in an Arduino IDE

We’ll program the ESP32-CAM board using Arduino IDE, so make sure you have it installed in your Arduino IDE. You can check out above video for that, there we have explained in detail about how to install ESP boards into an Arduino IDE

Software : Installing Libraries

For this project you need to install several libraries.

==> Telegram Bot Library, ArduinoJson Library

The following library can be installed through the Arduino Library Manager. Go to Sketch > Include Library> Manage Libraries and search for the library name.

==> Universal Telegram Bot Library

To interact with the Telegram bot, we’ll use the Universal Telegram Bot Library created by Brian Lough that provides an easy interface for the Telegram Bot API.

Follow the next steps to install the latest release of the library.

Click here to download the Universal Arduino Telegram Bot library.

  • Go to Sketch > Include Library > Add.ZIP Library...
  • Add the library you’ve just downloaded.
Important Note: don’t install the library through the Arduino Library Manager because it might get install a deprecated version.

For all the details about the library, take a look at the Universal Arduino Telegram Bot Library GitHub page.

Software

[Part - 2] Home Security System using ESP32 CAM and Telegram

Code of the project is given on our GitHub. We have explained code in above video, check out to learn more.

Software Setup - Apps

Monitoring and Controlling ESP Weather Station using Telegram App

In software setup, You need to complete following four steps

1. We need Telegram Application to be Installed on our smartphone.

2. Get Your Telegram Chat ID -

  • Why ? - To chat with an Authorized User ESPCAM needs USER ID / CHAT ID of our Telegram
  • Because anyone that knows your bot username can interact with it. To make sure that we ignore such spam messages that are not from our Telegram account (or any authorized users). We need to get our Telegram Chat ID.
  • Whenever your telegram bot receives a message, the ESP CAM Board can check whether the sender ID corresponds to your User ID and if it is correct then and then only it handle the message.

3. Create Telegram Bot -

  • Create Telegram bot for our Home Security Application/Project
  • Chat with Masterbot named “BotFather” to create a new bot

4. Get Bot Token -

  • When you create new bot – “BotFather” will issue a new bot token for your bot
  • Save the bot token because you’ll need it later (to Enter it in code) so that the ESP32 CAM can interact with the bot.
  • So we've explained all above steps in above video, check out and complete all above steps

Programming ESP32-CAM Dev Board

ESP32cam-How-To-Program-full.png
[Part - 3] Home Security System using ESP32 CAM and Telegram

To program the ESP32-CAM you need to setup above circuitry.

You can Check out above video, where we have explained How to program ESP32-CAM Dev Board

Demonstration

[Part - 4] Home Security System using ESP32 CAM and Telegram

The Final demonstration of project with all assembled circuit, all features and functionality is explained in above video

Source Code + Schematics + Libraries

You'll find all the information about this project on make2explore Github Repository