Hello guys I would like to have a project so that when the reed switch is triggered the wemos d1 mini wakes up, connects to wifi, send message and then deep sleep until triggered again.
I have a working code which basically lets me know the door is open or close while the blynk app is open and also notifies me when the blynk app is not running using the notification feature.
I need help your help with deep sleep so instead of having a 5v usb power connected to wemos d1 mini all the time, i can use some sort of rechargable battery pack
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
bool current = 0;
bool previous = 1;
char auth[] = "";
char ssid[] = "";
char pass[] = "";
BlynkTimer Mytimer;
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
Mytimer.setInterval(1000L, switchstate);
pinMode(14, INPUT_PULLUP); //DOOR
}
void switchstate(){
current = digitalRead(14);
if (current != previous){
previous = current;
if (current == LOW)
{
Blynk.virtualWrite(2, "Door closed.");
Blynk.notify("Your Door is closed!!");
}
else
{
Blynk.virtualWrite(2, "Door OPEN!");
Blynk.notify("Your Door is OPEN!!");
}
}
}
void loop()
{
Blynk.run();
Mytimer.run();
}