DTH11 Falied reading

Hello everyone. I´m having problems reading DHT11 sensor (3 pins). The connections are quite simple: Left pin (marked "S") attached to analog input 2; center pin to +5V and right pin (marked "-") to GND. The output is "nan - nan - nan" ans so on.... Here is the code. ¿Any suggestion?

#include <DHT.h> 
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
  
void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  delay(5000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

Serial.print(h);
Serial.print(" - ");
Serial.print(t);
Serial.print(" - ");
Serial.println(f);  
}

yes - give a link to the device you are using - eg

Comes with a 4.7K or 10K resistor, which you will want to use as a pullup from the data pin to VCC.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.