IOT security system | IOT Home Alarm | IoT Home Security System Project

(Last Updated On: August 18, 2019)

IOT Security System

Description:

IoT Security System- In this tutorial, you will learn how to make your own IoT based home/office security system using Nodemcu ESP8266 Wifi module, PIR Sensor, Infrared Sensor, and Blynk application. Each time an Intruder is detected a notification message is sent to the Blynk application. This is a real-time IOT based Security system. With the help of Nodemcu ESP8266 Wifi Module, the PIR Sensor and IR Sensor can be monitored from anywhere around the world.


In this tutorial, we will cover

  1. Complete circuit diagram explanation
  2. Interfacing
  3. Nodemcu Programming and finally
  4. Testing

Without any further delay, let’s get started!!!

The components and tools used in this project can be purchased from Amazon; the components purchase links are given below:

Nodemcu esp8266 wifi module: Best price https://amzn.to/2NAvmiB
LM7805 Voltage Regulator: https://amzn.to/2IZEl5x
PIR Sensor best package: https://amzn.to/2ZfhmeJ
IR infrared Sensor best package: https://amzn.to/2KI2z8G
330-ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 NPN transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
LDR pack: https://amzn.to/2m2khGR
female DC power jack socket: https://amzn.to/2KEo1gt
470uf capacitors: https://amzn.to/2xDCOzf
5×7 cm Vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / stripboard: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wirecutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF



Circuit Diagram:

IOT Security System

This Schematic is designed in CadeSoft Eagle 9.1.0 version. If you want to learn how to make a schematic and PCB then watch my tutorial, given below.

As you can see in this project two power supplies are used. The power supply on the left side is used to power up the Nodemcu ESP8266 wifi Module while the power supply on the right side is used to power up the PIR Sensor.  The voltage required to power up the PIR Sensor is from 5 to 20 volts as the PIR sensor module has a 3.3v voltage regulator. So the PIR Sensor module cannot be powered up using 3.3 volts from the Nodemcu Module. So that’s why I am using a separate 5v regulated power supply for the PIR Sensor. Both the Power Supplies are exactly the same and can be powered up using a single 12v adaptor.


J1 is the Female Power Jack and this is where we connect a 12v adaptor, battery, or a Solar panel. Two 470uf capacitors are connected at the input and output sides of the 7805 voltage regulator. A 330-ohm resistor is connected in series with a 2.5v LED. This is a current limiting resistor. The output of the voltage regulator is connected with the Vin pin of the Nodemcu ESP8266 Wifi module and the GND of the power supply is also connected with the ground of the Nodemcu Module.

The Out pin of the IR sensor is connected with the digital pin D1, VCC pin of the infrared sensor is connected with the 3v pin of the Nodemcu module while the GND is connected with the GND. The VCC pin of the PIR Sensor is connected with the output of the regulated power supply. The out pin is connected with the digital pin D0 and the ground pin is connected with the ground.

IOT Security System

This is the Final board after soldering, the PCB designing, online order placement, and soldering are already explained in my previous tutorial. The link to the video tutorial is already given above.


IOT Security System

This is the IR Sensor that I am going to use in this project. As you can see all the pins are clearly labeled with OUT, GND, and VCC. The white wire is connected with the OUT pin of the IR sensor and this will be connected with the digital pin D1 of the Nodemcu module, the brown wire is connected with the ground pin of the IR sensor and this will be connected with the ground of the Nodemcu module. The Red wire which is the VCC wire will be connected with the 3.3v pin of the Nodemcu module.

IOT Security System

This is the PIR Sensor. The leftmost pin is the VCC “Red Wire”. The middle one is the OUT “Yellow Wire” while the rightmost pin is the ground “Black Wire”. I have a very detailed getting started tutorial on the PIR sensor. So for the basic understanding, you should watch that tutorial which explains everything. You can find a link to the tutorial in the related projects section.


IOT Security System

This is the regulated 5 volts power supply based on the LM7805 voltage regulator. This power supply will be used to power up the PIR Sensor. The Orange wire is the 5v wire while the Blue wire is the ground wire.

Interfacing:

 

IOT Security System

All the components are interfaced as per the circuit diagram already explained. As you can see the output of this power supply is connected with the VCC pin of the PIR Sensor, while the out pin is connected with the D0 and Ground is connected with the ground.

The red wire from the IR Sensor is connected with the 3.3v pin of the Nodemcu module, the brown wire is connected with the ground while the out pin of the IR sensor is connected with the D1 pin of the Nodemcu module. One more thing make sure you connect the ground of the 5v power supply with the ground of the Nodemcu Module. So that’s all about the interfacing.



Blynk Application designing for IoT Security System:

Watch Video Tutorial given at the end which explains how to design the Blynk application or you can follow the following steps.

  • Open the Blynk application…
  • Click on the new project and enter the project name as IoT security system…
  • Click on the choose device and select Nodemcu…
  • Make sure you set the connection type to WIFI…
  • Finally, click on the create button, an authentication token will be sent on your email ID which will be then used in the programming. Simply copy and paste it in the programming…
  • Now click on the screen and search for the LED…
  • Click again on the screen and add another LED…
  • Click again on the screen and this time search for the terminal widget and add it…
  • Finally, add a notification widget…
  • Click on the first LED set the name and select the virtual pin V2…
  • Now click on the 2nd LED to set the name and select virtual pin V3…
  • Finally, click on the terminal widget, set the name and select virtual pin V4…
  • Set add a new line to yes and input line to off…so that’s all about the application designing.

IoT Security System Programming “Nodemcu”:


IOT Security System Program Explanation:

Before you start the programming, first of all, make sure that you download the following libraries. You can find the link in the related projects section.

 

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <SoftwareSerial.h>

#include <SimpleTimer.h>

char auth[] = “DyWieVh9EKgPbrDQAapbwWVFBJXN_Bqv”;

This is the authentication number which was sent via email.

char ssid[] = “ZONG MBB-E8231-6E63”;

This is the name of the wifi router

char pass[] = “electroniclinic”;

This is the password.

void myTimerEvent()

{

// You can send any value at any time.

// Please don’t send more that 10 values per second.

Blynk.virtualWrite(V1, millis() / 1000);

}

This is the same function I have been using in all of my IoT based projects.

int pir_s = D0; // PIR sensor

int ir_s = D1;  // infrared sensor

The PIR sensor is connected with the digital Pin D0 of the Nodemcu Module and the Infrared Sensor is connected with the digital pin D1.

Unlike the Arduino and Mega, the Nodemcu ESP8266 WIFI module also has at least two functions which are the void setup and void loop functions. The programming of the Nodemcu module is just like the Arduino and Mega.

void setup()

{

// Debug console

Serial.begin(9600);

Blynk.begin(auth, ssid, pass);

pinMode(pir_s, INPUT_PULLUP);

pinMode(ir_s, INPUT);

timer.setInterval(1000L,sensorvalue1);

}

In the void setup function I activated the serial communication. 9600 is the baud rate.

Then using the pinMode function I set both the sensors to input.

Sensorvalue1 is a user defined function and this function is called every 1 second.

void loop()

{

Blynk.run();

timer.run(); // Initiates BlynkTimer

}

Then starts the void loop function.  inside this function, we have only Blynk.run and timer.run functions.

As I said earlier sensorvalue1 is a user-defined function. This function has no return type and does not take any arguments as the input. Inside this function, we are using if conditions to check which sensor is activated. I have already explained all of these instructions in my previous tutorials. I have a separate video on how to use the notification widget. This program is very simple. Still, if you have any questions let me know in a comment. So that’s all about the programming.

This project was a great success, I successfully detected both the sensors which you can practically see in the video given below.



Watch Video Tutorial:

 

Related Projects:

Arduino Libraries Download and Projects they are used in “Project codes”

 

Arduino PIR Sensor Code, Sensitivity, Datasheet, and Range “Passive Infrared Sensor”

 

 

 

 

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Close