Esp8266IOT Projects

 IOT theft Notification Using Blynk : Door Status

One of the best application of IOT is the Home Security and there are like a bunch of IOT platforms that have dedicated APIs for the same, which offers the real time status of the sensor or devices operating as a security check.

In this, tutorial we are going  to make a IOT Home Security system where we will be able to get the notification on our phone every time the gate is opened. Here, we are using NodeMCU with Blynk App(Know more about Blynk). The sensor which we are using is a Magnetic Door Switch and is readily available at any electronnic shop. It is basically a reel switch that gets ON when subjected to a magnet nearby. It is very cheap and can be made easily, using some basic components.

Working principle is very simple whenever the gate opens as a result the magnet gets seperated from the reel switch  and the circuit inside the switch breaks, this braking of circuit triggers the NodeMCU to send a status update to Blynk Server that push a notification on our phone about the event of opening the door and we are able to get the door’s open notification  status on our phone in anywhere in the world via internet connectivity.

Component Required : 

  • NodeMCU 12E (or any ESP based dev. Board)
  • Magnetic Door Switch
  • Mini Breadboard
  • Few jumpers (options)

Magnetic Switch : 

Connection :

Blynk App Building:

Step 1. Open the Blynk and Select new project. Name the new project and select the board ‘NodeMCU’ and then click the Create button.

Step 2. Click the + icon and add Notification Widget.

Step 3. Go to your phone’s notification setting and Allow notifications for Blynk App.


Code Section:

Here you have to replace the auth token to the one which you have recieved in your Email during the making of the App.

Also, change the SSID and Pass to your WiFi or Hotspot name and Password respectively.

Note: Blynk allow only one notification per 15 seconds. So sometimes it can take a little more seconds then usuall to get a notification on your phone .

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "f016e1d31abf4b95a28b6466c10348f1";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "CPH1613";
char pass[] = "alok123456";
int flag=0;

void notifyOnButtonPress()
  int isButtonPressed = digitalRead(D1);
  if (isButtonPressed==1 && flag==0) {
    Serial.println("Someone Opened the door");

    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("Alert : Someone Opened the door");
  else if (isButtonPressed==0)

void setup()
  // Debug console

Blynk.begin(auth, ssid, pass);
  // Setup notification button on pin D1
void loop()
{;; // Initiates BlynkTimer


Show More

Related Articles

Leave a Reply

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

Check Also

Back to top button