Last active
November 18, 2020 11:09
-
-
Save structure7/eee51b3851303c850a7ca9e5eeb93f3e to your computer and use it in GitHub Desktop.
Blynk mailbox sensor (mosfet + reed switch + WeMos)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SimpleTimer.h> | |
//#define BLYNK_PRINT Serial // Comment this out to disable prints and save space | |
#include <BlynkSimpleEsp8266.h> | |
extern "C" { | |
uint16 readvdd33(void); | |
} | |
char auth[] = "fromBlynkApp"; | |
const char* ssid = "ssid"; | |
const char* pw = "pw"; | |
const int gate = 5; // Mosfet gate on WeMos D1 Mini pin D1 (formerly D4... was draining my battery when off!) | |
SimpleTimer timer; | |
void setup() { | |
pinMode(gate, OUTPUT); | |
digitalWrite(gate, LOW); | |
Serial.begin(9600); | |
Blynk.begin(auth, ssid, pw); | |
while (Blynk.connect() == false) { | |
// Wait until connected | |
} | |
float vdd = readvdd33() / 1000.0; | |
//Blynk.notify(WiFi.RSSI()); | |
Blynk.notify(String("You've got mail! (batt=") + vdd + "v)"); | |
timer.setTimeout(1000L, shutDown); | |
} | |
void loop() { | |
Blynk.run(); | |
timer.run(); | |
} | |
void shutDown() { | |
digitalWrite(gate, HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment