How to make a home security system using Nodemcu ESP8266 and Blynk app

PIR security system with Nodemcu and blynk app

Hello, welcome back to another tutorial from the SriTu Hobby. In this tutorial, we will learn how to make a home security system using the Nodemcu ESP8266 board and the Blynk application. Also, the PIR sensor is mainly used for this project. We have done this project using the Telegram app in a previous article. You can study it from this link. Also, this project can be used for our home, place of business, shops. So this tutorial will cover how to make this project at a low cost. Keep reading.

How does this security system work?

When this security system is powered on, The Nodemcu board connects to the Blynk cloud via the internet. Then we can turn ON and OFF this system using the button on the interface set up in the Blynk app. After, when a motion is captured by the PIR sensor, the buzzer and the red LED are activated. Then, the mobile phone also receives a push notification via the Blynk app. Afterward. this system will return to normal after a short time. Also, this time can be changed by the preset in the PIR sensor. The green LED bulb turns ON when the system is operating normally.

OK, let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Nodemcu ESP8266 board

PIR sensor

LED bulb x 2

180-ohm resistor x 2

5v buzzer

Jumper wires

Foamboard

Step 2

Secondly, cut the foam board pieces as follows.How to make a home security system using Nodemcu ESP8266 and Blynk app

Step 3

Thirdly, solder the jumper wires for the buzzer and LEDs.How to make a home security system using Nodemcu ESP8266 and Blynk app

How to make a home security system using Nodemcu ESP8266 and Blynk app
How to make a home security system using Nodemcu ESP8266 and Blynk app

Step 4

Next, connect all the components to the Nodemcu board. To do this, use the circuit diagram below.How to make a home security system using Nodemcu ESP8266 and Blynk app

How to make a home security system using Nodemcu ESP8266 and Blynk app
How to make a home security system using Nodemcu ESP8266 and Blynk app
How to make a home security system using Nodemcu ESP8266 and Blynk app

Step 5

Then, adjust a 1.5 x 3.5-inch piece to fit the Nodemcu board and glue it on.Then, adjust a 1.5 x 3.5 inch piece to fit the Nodemcu board and glue it on.

Step 6

Next, set a 2.5 x 3.5-inch piece to fit the PIR sensor and the two LEDs.After, glue them.Next, set a 2.5 x 3.5 inch piece to fit the PIR sensor and the two LEDs.After, glue them

Next, set a 2.5 x 3.5 inch piece to fit the PIR sensor and the two LEDs.After, glue them
Next, set a 2.5 x 3.5 inch piece to fit the PIR sensor and the two LEDs.After, glue them
Next, set a 2.5 x 3.5 inch piece to fit the PIR sensor and the two LEDs.After, glue them

Step 7

Then, take a 1.5 x 3.5-inch piece and adjust it to fit the buzzer. After, glue it on.Then, take a 1.5 x 3.5 inch piece and adjust it to fit the buzzer.

Step 8

Now, connect the piece that holds the Nodemcu board to the 3.5 x 2.5-inch piece.Now, connect the piece that holds the Nodemcu board to the 3.5 x 2.5 inch piece.

Now, connect the piece that holds the Nodemcu board to the 3.5 x 2.5 inch piece.

Step 9

Then, glue the 1.5 x 2.5-inch piece to the base foam board piece. Also, glue the buzzer-connected piece to the base piece.Then glue the 1.5 x 2.5 inch piece to the base foam board piece. Also, glue the buzzer-connected piece to the base piece

Then glue the 1.5 x 2.5 inch piece to the base foam board piece. Also, glue the buzzer-connected piece to the base piece

Step 10

Next, glue the 1.5 x 2.5-inch piece to the main foam board piece. Also, glue the PIR sensor attachment piece to the top as follows.Also, glue the PIR sensor attachment piece to the top as follows

Also, glue the PIR sensor attachment piece to the top as follows
Also, glue the PIR sensor attachment piece to the top as follows

Step 11

Ok, now let’s set up the Blink app step by step.

  • First, download and install the Blynk app from your mobile phone. Then, sign up for this app using your Gmail. Next, click the new project button.First, download and install the Blynk app from your mobile phone. Then, sign up for this app using your Gmail. Next, click the new project button.
  • Then, enter the project name as you like. Also, select the device and connection type. After. Click the “Confirm” button.
  • Then, enter the project name as you wish. Also, select the device and connection type. After. Click the "Confirm" button.
  • Now, we can see the project interface. Then, click the “+” icon and add one button and notification widget.
    Now we can see the project interface. Then, click the "+" icon and add one button and notification widget.
Now we can see the project interface. Then, click the "+" icon and add one button and notification widget.
Now we can see the project interface. Then, click the "+" icon and add one button and notification widget.
Now we can see the project interface. Then, click the "+" icon and add one button and notification widget.
  • Then, click the button and enter the name of your choice. Next, change the pin to A0 and the mode as the switch. Afterward, click the Notification Widget and change the priority to HIGH.how-to-make-a-home-security-system-using-nodemcu-esp8266-and-blynk-app
how-to-make-a-home-security-system-using-nodemcu-esp8266-and-blynk-app

Step 12

OK, the Blynk app is ready. Now, connect this project to the computer. After that, let’s create the program for this project. It is as follows.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = ""; //Enter your Blynk application auth token
char ssid[] = ""; //Enter your WIFI name
char pass[] = ""; //Enter your WIFI passowrd

BlynkTimer timer;
int pinValue = 0;

void setup() {
  Serial.begin(9600);
  pinMode(D0, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D6, INPUT);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, notifiaction);

}
BLYNK_WRITE(V0) {
  pinValue = param.asInt();
}

void notifiaction() {
  bool sensor = digitalRead(D3);
  Serial.println(sensor);
  if (pinValue == 1) {
    Serial.println("System is ON");
    if (sensor == 1) {
      Blynk.notify("WARNING! Please check your security system");
      digitalWrite(D0, HIGH);
      digitalWrite(D1, HIGH);
      digitalWrite(D2, LOW);
    } else if (sensor == 0) {
      digitalWrite(D0, LOW);
      digitalWrite(D1, LOW);
      digitalWrite(D2, HIGH);
    }
  } else if (pinValue == 0) {
    Serial.println("System is OFF");
  }
}

void loop() {
  Blynk.run();
  timer.run();
}

Code Explanation

Firstly, it includes WIFI and Blynk libraries.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

Secondly, enter your Blynk app token and WIFI connection details.
char auth[] = “BMFz-z1357p65VVCAcsWTPfg_K-Jcuwj”; 
char ssid[] = “Dialog 4G 025”; 
char pass[] = “12345”; 

Secondly, enter your Blynk app token and WIFI connection details.
Secondly, enter your Blynk app token and WIFI connection details.

Next, variables were created for BlynkTimer and Button Widget.
BlynkTimer timer;
int pinValue = 0;

In the void setup, the LEDs, buzzer and sensor pins are set as output. Also, the Blynk library starts using the Auth token, WIFI name, and WIFI password. Later, the notification function is called. The notification function is described below.
void setup() {
Serial.begin(9600);
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D6, INPUT);

Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, notifiaction);

}

void notifiaction() {
First, values are obtained from the PIR sensor and these values are entered into the boolean variable. Also, these values are printed on the serial monitor
bool sensor = digitalRead(D3);
Serial.println(sensor);

If the Blynk app button value is 1, the system is activated. Also, it is printed on the serial monitor.
if (pinValue == 1) {
Serial.println(“System is ON”);

Then, PIR sensor values are checked using the IF condition. If the value is 1, a push notification is sent to your phone and the red LED and buzzer are activated.
if (sensor == 1) {
Blynk.notify(“WARNING! Please check your security system”);
digitalWrite(D0, HIGH);
digitalWrite(D1, HIGH);
digitalWrite(D2, LOW);

If the value is 0, the green LED is active.
} else if (sensor == 0) {
digitalWrite(D0, LOW);
digitalWrite(D1, LOW);
digitalWrite(D2, HIGH);
}

If the Blink application button value is 0, the system deactivates. Also, it is printed on the serial monitor.
} else if (pinValue == 0) {
Serial.println(“System is OFF”);
}
}

This code receives values from the blynk Button Widget.
BLYNK_WRITE(V0) {
pinValue = param.asInt();
}

In the loop function, the blink library and timer are activated.
void loop() {
Blynk.run();
timer.run();
}

Step 13

OK, now select the board and port. Then, upload this code to the Nodemcu board.

Step 14

Now, run the Blynk app interface and enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.

How to make a home security system using Nodemcu ESP8266 and Blynk app

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *