17. Door Notification System
Overview of Magnetic Door Sensor
Door sensors have one reed switch and one magnet, creating a closed circuit. If someone opens an armed door or window, the magnet is pulled away from the switch, which breaks the circuit and triggers an event. Depending on your setup and what mode your system is in, this could be a discreet text, a chime alert, or a full-blown alarm.
Connection of Magnetic Door Sensor
In magnetic Door sensor have not Positive and Negative terminals. So, you can connect One terminal to D1 pin of NodeMCU and another Terminal to Ground of NodeMCU as shown in figure.
Program
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
int flag=0;
// You should get Auth Token in the //Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "WRSu1DJITg2rSoBDuefgaWdMnCfBWDCY";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "manish";
char pass[] = "manish8294";
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(D1, INPUT_PULLUP);
timer.setInterval(16000L, notifyOnButtonPress);
}
void notifyOnButtonPress()
{
int isButtonPressed=digitalRead(D1);
if(isButtonPressed==1 && flag==0)
{
Serial.println("Someone open the door");
Blynk.notify("Alert: Someone opened the door");
flag=1;
}
else if(isButtonPressed==0)
{
flag=0;
}
}
void loop()
{
Blynk.run();
timer.run();
}
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
int flag=0;
// You should get Auth Token in the //Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "WRSu1DJITg2rSoBDuefgaWdMnCfBWDCY";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "manish";
char pass[] = "manish8294";
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(D1, INPUT_PULLUP);
timer.setInterval(16000L, notifyOnButtonPress);
}
void notifyOnButtonPress()
{
int isButtonPressed=digitalRead(D1);
if(isButtonPressed==1 && flag==0)
{
Serial.println("Someone open the door");
Blynk.notify("Alert: Someone opened the door");
flag=1;
}
else if(isButtonPressed==0)
{
flag=0;
}
}
void loop()
{
Blynk.run();
timer.run();
}
Method of Connecting Blynk App
Step1: Go-to play store in your mobile phone and download Blynk App and open app and make account in Blynk App as shown in Figure.
Step2: Now click on new Project and Enter name of project and choose device and Connection Type according to below figure. Then Click on Create.
Step3: After, click on Crete Button You get Authorization Token of the project And click on Ok. The authorization Token directly Send In your Registered Email ID.
Step4: Now, your project has created. Then, you click on +icon to open the Widget Box And choose Notification as shown in figure. After, choosing Notification you see in Project Window the notification bar is present as shown in figure.
Step5: Now open the Email id. Where Authorization key is sent by the Blynk app and copy the Authorization key and Paste in the Code. In code you enter WIFI ssid and Password and upload the Code in NodeMCU as shown in figure.
Step6: open Blynk App and click on play button you see your blink app is connected to the NodeMCU and you get Notification when your door is open as shown in figure.
Note: After, done above process Your Door Notification System is Work. in case Your Blynk App Notification is not on then You have not gotten Notification. So, you go to phone Setting and check your Blink App notification setting is On or OFF.
Comments
Post a Comment