DHT11 Works, unless I use Blynk.begin()

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();
}

My solution, similar problem but with a different DHT sensor, was to use the TroykaDHT.h library.

        Serial.begin(115200);
        delay(5000); // Allow board to settle
        // Start Blynk
        Blynk.begin(auth);
        // Start DHT sensor
        dht.begin();

Maybe a short delay to allow the board to settle the sensor?

I copied from my working project here:

https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=More%2FDHT11

1 Like