PIR Motion Capture Security System

Published Sep 23, 2021
 10 hours to build
 Advanced

There has been drastic increase in theft and burglary, robbing of houses, stores, shops and banks etc. This research focuses on how to configure a simple home security framework using a PIR sensor (Passive Infra-Red) in light of a microcontroller. PIR motion sensor used detects the motion of the person entering the house.

display image

Components Used

Breadboard
Breadboard
1
PIR Sensor
PIR motion sensors sense the Infrared signal radiated from moving objects including human or animal body. It is generally used to detect the presence of human or animal motions.
1
USB TO TTL Converter
Interface Modules USB TO TTL 3.3V 1 PORT WITH DB9M
1
ESP32-CAM Development Board
WiFi Development Tools - 802.11 ESP32-CAM Development Board
1
Description

1. Description 

A security framework that can have the option to recognize and screen the zone and respond viably to security danger is in incredible need. Because of the expanding number in wrongdoing and theft, the requirement for a proficient security framework is fundamental. There are now loads of security frameworks in the realm of innovation as of now, in the market for both indoor and outdoor applications, for example, Ultrasonic identifiers, CCTV, microwave indicators, photoelectric finders, infrared locators and so forth.

Anyway the greater part of these frameworks of being costly in the market, or they require increasingly electrical force development, more memory space of usage of the account framework and complex circuity, and so on. Accordingly an answer for conquer these issues could be by utilizing a sensor of minimal effort which can identify the interlopers, and other security astonishingly inside the sensor's discovery run and creates and yield.

This yield is can likewise be utilized to additionally flagging and actuating other security gadgets like caution framework, helping framework and other comparable security danger gadgets. Which means this framework can spare force utilizations on the grounds that these segments get activated just when there are gate crashers and security dangers in the sensor's discovery run. A Passive Infrared radiation motion sensor is security based system that saves the power consumption and the memory space of the recording system.

Passive Infrared Radiation (PIR) sensor detects the change in infrared radiation of warm blooded moving   object in its detection range. The use of motion detectors goes back to ancient societies that developed   agriculture and motion detection of people and things can be traced back to the early decades of the 20th century, with many of the same principles still in use today [1]. The objective of this work is to develop a simplified version of a PIR sensor which can be installed on campus and houses for lightening systems, shops  and  malls for security systems and other major applications and places all over the globe. In order to understand the full ideal of this project, we need to review the history of motion detection and how it came to surface between the 20th and 21st century.


You can see the step by step to make this project and final output 

 

2. Components Used

          2.1 PIR Sensor

All living objects, whose body temperature is more than 0oC, emit the heat in form of infrared radiation through their body, also called as thermal radiations. This Radiated energy is invisible to human eye. These Signals can be detected by using PIR sensor which is specially designed for such purpose

Grid Eye Illusion
Grid eye illusion
 

In Passive Infrared (PIR) Sensor, passive word indicates PIR Sensor does not generate or radiate any energy for detection purposes.

PIR Sensors don't detect or measure "HEAT"; they detect the infrared radiation emitted or reflected from objects.

They are small, inexpensive, low power and easy to use. They are commonly found at home, medical, factories etc. areas.

         

 

PIR Sensor Pin Description
Pin Diagram of PIR Sensor
 

Pin 1 – GND

We have to connect this pin to Ground.

Pin 2 – Output

This pin gives output (3.5V) when the motion is detected.

Pin 3 – VCC

This pin provides supply voltage(+5v) to PIR element and internal circuit.

 

          2.2 USB TO UART TTL

USB TO UART TTL

The USB TO UART TTL 5V 3.3V FT232RL Download Cable To Serial Adapter Module is a basic breakout board for the FTDI FT232RL USB to serial IC, Revision 2. The pinout of this board matches the FTDI cable to work with official Arduino and cloned 5V Arduino boards. It can also be used for general serial applications.

The major difference with this board is that it brings out the DTR pin as opposed to the RTS pin of the FTDI cable. The DTR pin allows an Arduino target to auto-reset when a new Sketch is downloaded. This is a really nice feature to have and allows a sketch to be downloaded without having to hit the reset button. This board will auto reset any Arduino board that has the reset pin brought out to a 6-pin connector.

  1. Standard interface layout, compatible with a variety of Arduinos such as the Pro Mini
  2. Original FTDI FT232 chip, stable performance
  3. USB power has current protection, using 500MA self-restore fuse
  4. RXD/TXD transceiver communication indicator
  5. With power, sending, receiving indicator, working status LED indicators
  6. Mini USB Port Connection
  7. Support 3.3V, 5V

     

          2.3 ESP32-Cam Pinout(AI-Thinker module):

 

esp32-cam-pinout

There are three GND pins and two pins for power: either 3.3V or 5V.

GPIO 1 and GPIO 3 are the serial pins. You need these pins to upload code to your board. Additionally, GPIO 0 also plays an important role, since it determines whether the ESP32 is in flashing mode or not. When GPIO 0 is connected to GND, the ESP32 is in flashing mode.

3. System Design

The sensor can detect the presence of intruders. Upon detection of IR, PIR sensor generates the output in the form of electrical signal. Although the output from the sensor is of few volts, it could be amplified to required voltage using amplifier circuit and could be used for actuating lighting system and the webcam. The lamp and webcam could be turned ON when the PIR sensor is activated and could remain OFF when the sensor is idle. This way, the energy consumed by the overall system could be minimized. Also the cost of system could be far less than the security system available in the market. With this hypothesis, we have proposed a simple low power PIR based security system. It consists of connecting lighting system and webcam to the PIR senor and software development for the recording video captured by webcam on the computer. The system works in the following steps:

i.  The software developed is kept running and checks if the cam is turned ON.

ii. When an intruder comes in the detection range of the PIR sensor, the sensor generates an output of 3.3 volts.

iii. This output is further amplified and is used for activating the relay of the lighting system and the webcam.

iv. Once the lamp and webcam are actuated with the output from the amplifier, software finds the webcam is turned   ON.

v. The software starts to  capture the photo by the esp32 cam

vi. After the intruder leaves the detection range of the sensor, there is no output from the sensor. Therefore, it turns   OFF the webcam. The photo captured will be sent to telegram.

vii. Every time when the intruders come in the detection range of the sensor, the above steps from step 2 to step 6 repeats.

 

4. Software Setup

 

What Are Telegram Bots ?

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

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.

 

5. Methodology

              A Home Security  is needed to be designed  for the safety, this is controlled with help of internet using the ESP32 CAM module. It have PIR Motion sensor fixed to it in order to detect the motion. When PIR Sensor produces warning alert to the ESP32 CAM and immediately it take the photos and it will send to the telegram application with the help of internet. An Overall block diagram is shown below, Now let’s see how photo is sent to telegram, In telegram I created an TELEGRAM BOT  and I got an API KEY and with the help of that API key, I created a Code. I uploaded the code to ESP32 module using TTL programmer.

When Motion detected the PIR sensor send a signal to ESP32 module  and esp32 take photo and send to telegram user 

I created using API key over internet. It can send to telegram application no matter where we are in the world. The system includes the brain of the robot, ESP32 Cam, PIR Sensor sensor, TTL Programmer.

 

Block Diagram For Code Uploading
Overall Block Diagram

 

6. How the Code Works

      Libraries

const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

     Telegram Bot Token

#define BOTtoken "XXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"  // your Bot Token (Get from Botfather)

     Telegram User ID

         Insert your chat ID. The one you’ve got from the IDBot.

#define CHAT_ID "XXXXXXXXXX"

    detectsMovement()

         The detectsmovement() function is a callback function that will be executed when motion is detected. In this case, it simply changes the state of the motionDetected variable to true.

void IRAM_ATTR detectsMovement() {
  //Serial.println("MOTION DETECTED!!!");
  motionDetected = true;
}

  loop()

  In the loop(), check the state of the motionDetected variable.

void loop() {
  if(motionDetected){

If it’s true, it means that motion was detected. So, send a message to your Telegram account indicating that motion was detected.

bot.sendMessage(CHAT_ID, "Motion detected!!", "");

Sending a message to the bot is very simply. You just need to use the sendMessage() method on the bot object and pass as arguments the recipient’s chat ID, the message, and the parse mode.

bool sendMessage(String chat_id, String text, String parse_mode = "")

Finally, after sending the message, set the motionDetected variable to false, so it can detect motion again.

motionDetected = false;

That’s pretty much how the code works.

VIDEO

 

7. OUTPUT

    In this PIR Sensor Based Security System, we have used low power, low cost PIR sensor that are  easy to interface with other components. By using this system we were able to reduce the power consumed and memory space of the system. Currently, we have used only one webcam in our project which could only capture the area facing to it. The system may not work if the intruders enter from other side. The software developed for the recording of the video captured by the webcam is experimented only with a webcam connected to the system also there was some delay in recording video captured by the webcam. Considering all above points, followings are our future works set to improve the system:

• Work on to reduce the delay time in recording the video captured by webcam.

• Use more than one webcam and integrating these webcams with the system.

• Work on the software to record videos from many webcams installed.

     Alert Image received in          Telegram App

                                                     Project Setup

Codes

Downloads

Esp32 To PIR Download
TTL To Esp32 Download
EW Project Challenge 2021 Documentation Download

Institute / Organization

RMD ENGINEERING COLLEGE
Comments
Ad