i'm just wondering how i can attach a reed sensor to the nodemcu and monitor its status in the blynk app?
here's the sketch:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 12
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "********";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "********";
char pass[] = "********";
SimpleTimer timer;
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,166), 8442);
// Setup a function to be called every second
timer.setInterval(1000L, sendUptime);
}
void sendUptime()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(10, DHT.temperature); //virtual pin
Blynk.virtualWrite(11, DHT.humidity); // virtual pin
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
int chk;
chk = DHT.read(DHT11_PIN); // READ DATA
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}