IoT Security System-Using the Nodemcu ESP8266 Wifi unit, PIR Sensor, Infrared Sensor, and Blynk software, you can learn how to make your own IoT based home/office security system. Every time a warning message is sent to the blynk application When the intruder is identified.
In this post, we will cover
- Complete circuit diagram and explanation
- Nodemcu Programming and finally
Let’s continue without any further delay!!!
The Amazon purchase links are given below:
Nodemcu esp8266 wifi module: Best price https://amzn.to/2ZzhWpz
LM7805 Voltage Regulator: https://amzn.to/39qx6Sv
PIR Sensor best package: https://amzn.to/2SAFUzl
IR infrared Sensor best package: https://amzn.to/37lc5XO
Arduino Uno: https://amzn.to/39aq6ZT
Mega 2560: https://amzn.to/2SszMsI
lm7805 Voltage Regulator: https://amzn.to/2ERYoTJ
330-ohm resistors pack: https://amzn.to/2Qj1Igg
female DC power jack socket: https://amzn.to/377Pg9M
470uf capacitors: https://amzn.to/2MrN3xR
5×7 cm Vero board: https://amzn.to/37b7KWO
female headers: https://amzn.to/350w6RE
connection wires: https://amzn.to/2MvOJXd
Super Starter kit for Beginners: https://amzn.to/398dliF
Jumper Wires: https://amzn.to/2SrnBwo
Bread Board: https://amzn.to/2MxV5FM
12v Adaptor: https://amzn.to/2MuOlZk
PCB plate: https://amzn.to/2MuwNMB
Variable Supply: https://amzn.to/39d0KdP
Digital Multimeter: https://amzn.to/34WbVoa
Vero Board / stripboard: https://amzn.to/39nL9Zg
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2PVwexF
Solder wire: https://amzn.to/2QlOvTS
Wire Stripper: https://amzn.to/353tYJa
PCB small portable drill machine: https://amzn.to/2MvQqnx
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
This scheme is built in version 9.1.0 of CadeSoft Eagle.
Two power supplies are being used, as you can see in this project The left-hand power supply is used to power the Nodemcu ESP8266 wifi module while the right-hand power supply is used to power the PIR sensor. As the PIR sensor module has a 3.3v voltage regulator, the voltage required to power up the PIR sensor is from 5 to 20 volts.So the Nodemcu system can’t power up the PIR Sensor module with 3.3 volts. That’s why I use the PIR Sensor with a separate 5v controlled power supply. All power supplies are essentially the same and can be powered by a single 12v adapter.
J1 is the Female Power Jack and this is where we attach a 12v converter, battery or solar panel. Two 470uf capacitors are attached to the input and output sides of the 7805 voltage regulator. A 330 ohm resistor is connected to a 2.5v LED series.This is an ongoing resistor restricting. The voltage regulator output is connected to the Nodemcu ESP8266 Wifi module’s Vin pin and the Nodemcu module ground is also connected to the power supply’s GND.
The IR Sensor’s out pin is connected to the infrared sensor’s digital pin D1, VCC pin is connected to the Nodemcu module’s 3v pin while the GND is connected to the GND. The PIR Sensor’s VCC pin is connected to the controlled power supply output. The out pin attaches to the digital pin D0 and links the ground pin to the ground.
This is the final board that is already discussed in my previous tutorial after soldering, PCB layout, online order placement, and soldering.
This is the IR Sensor I will be using in this project. All the pins are clearly marked with OUT, GND, and VCC as you can see. The white wire is connected to the IR sensor’s OUT pin and this is connected to the Nodemcu module’s digital pin D1,The brown wire is attached to the IR sensor ground pin and is connected to the Nodemcu unit board. The Red cable, the VCC wire, is attached to the Nodemcu module’s 3.3v socket.
This is the detector for PIR. The left pin is the “Red Wire” VCC. The middle one is the “Yellow Wire” and the right pin is the “Black Wire” surface. I have started a very comprehensive PIR sensor tutorial. So you should look at that tutorial to explain everything for the basic understanding.
As explained in the circuit diagram, all the components are interfaced. As you can see, this power supply’s output is connected to the PIR Sensor’s VCC pin, while the out pin is connected to the D0 and the input is connected to the ground.
The IR Sensor’s red wire is connected to the Nodemcu module’s 3.3v pin, the brown wire is connected to the ground while the IR sensor’s out pin is connected to the Nodemcu module’s D1 pin. Another thing is to make sure that you connect the 5v power supply ground with the Nodemcu Module ground. So the interfacing is all about that.
Blynk Application designing for IoT Security System:
- Tap on the new project and type the project name as an IoT security system …
- Tap on the computer you have selected and pick Nodemcu …
Make sure you set the form of WIFI connection …
- Finally, click the Create button to send an authentication token to your email ID, which is then used in the programming process. Just copy it and paste it into the programming…
- Now click on the screen and search for the LED…
- Click on the screen again and add another LED…
- Click on the screen again and this time search for the terminal widget and add it…
- Finally, add a notification widget …
- Click the first LED to set the name and select the virtual pin V2 …
- Now click the 2nd LED to set the name and select the virtual pin V3 …
- Finally, click the terminal widget, set the name and select the virtual pin V4 …
- Set to add a new line to yes and input line to off …
- so that’s all about designing the application.
IoT Security System Programming “Nodemcu”:
#define BLYNK_PRINT Serial
char auth = "DyWieVh9EKgPbrDQAapbwWVFBJXN_Bqv";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "ZONG MBB-E8231-6E63";
char pass = "electroniclinic";
// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, millis() / 1000);
int pir_s = D0; // pir sensor
int ir_s = D1; // infrared sensor
// Debug console
Blynk.begin(auth, ssid, pass);
timer.run(); // Initiates BlynkTimer
if(digitalRead(pir_s) == HIGH)
Blynk.virtualWrite(V2,255 ); // turns on the led
Blynk.virtualWrite(V4,"Intruder detected on PIR Sensor!!!" );
Blynk.notify("Intruder detected on PIR Sensor!!!");
if(digitalRead(pir_s) == LOW)
Blynk.virtualWrite(V2,0 ); //turns off the led
Blynk.virtualWrite(V4,"PIR Normal" );
if( digitalRead(ir_s) == LOW)
Blynk.virtualWrite(V3,255 ); // turns on the led
Blynk.virtualWrite(V4,"Intruder detected on IR Sensor!!!" );
Blynk.notify("Intruder detected on IR Sensor!!!");
if( digitalRead(ir_s) == HIGH)
Blynk.virtualWrite(V3,0 ); // turns off the led