Trying to make a door sensor with a reed switch (usintg the D1 and GND pin) for my project, but no notifications show up. Asking for assistance. Below's my code:
#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxxxxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "xxxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
BlynkTimer timer;
int flag=0;
int ReedSwitch = 1;
void notifyOnButton(){
int isButtonPressed = digitalRead(ReedSwitch);
if (isButtonPressed == HIGH) {
Serial.println("Someone Opened the door");
Blynk.notify("Alert : Someone Opened the door");
flag=1;
}
else if (isButtonPressed == LOW)
{
flag=0;
}
}
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(ReedSwitch, INPUT_PULLUP);
timer.setInterval(16000L, notifyOnButton);
}
void loop() {
Blynk.run();
timer.run();
}