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