I’m using a nodemcu es8266 to read the temperature from the DHT11. I’ve posted my code below, and it works until I uncomment the line where I have my Blink.begin() statement. This seems to be the only thing that causes my DHT11 to go from working to returning NaN values. I’m not sure how to get this to work, but I’ve isolated the cause to the parts of the code that connect to Blynk.
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define DHTTYPE DHT11
#define DHTPIN 14
DHT dht(DHTPIN, DHTTYPE);
#define BLYNK_PRINT Serial
BlynkTimer timer;
char auth[] = "xxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxxi";
char pass[] = "xxxxxx";
void setup() {
Serial.begin(115200);
dht.begin();
timer.setInterval(2000L, sendSensor);
// Blynk.begin(auth, ssid, pass);
}
void sendSensor() {
float f = dht.readTemperature(true);
if(isnan(f)) {
return;
}
Serial.println(f);
// Blynk.virtualWrite(V6, f);
}
void loop() {
// Blynk.run();
timer.run();
}