Hi all, new to this forum and Arduino. I'm trying to run a DHT11, but it keeps returning values that are way off. My ambient humidity and temperature are 22 degrees C and ~50% humidity, but the values I get back are 10 to 11 degrees C or -10 to -11 degrees C and 150-165% humidity. My code is as follows:
#include <DHT.h>
#include <DHT_U.h>
#define dht_pin0 A5
#define DHT0Type DHT11
DHT dht0(dht_pin0, DHT0Type);
void setup() {
Serial.begin(9600);
}
void loop() {
float readTemperature0 = dht0.readTemperature();
float readHumidity0 = dht0.readHumidity();
Serial.println(readTemperature0);
Serial.println(readHumidity0);
delay(1000);
}
I get similar measurements for multiple sensors, so I don't think that's the issue. I've also tried multiple analog input pins. The 5V and GND pins work fine to turn on a relay, so I don't think that's the problem either.
In case it is helpful information, I get nan more often than not in all the ways I've tried wiring.