Reputation: 57
I am using DHT11 sensor for displaying humidity and temperature values. I dont know where I did wrong. It's displaying only -999 value for both humidity and temperature. Here's my code
#include <dht.h>
dht DHT;
#define DHT11_PIN A0
void setup(){
Serial.begin(9600);
}
void loop()
{
DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
delay(1000);
}
Upvotes: 1
Views: 703
Reputation: 64
Your code seems to be correct. Try to make different connections and use different libraries. If it is still not solved then I recommend you to get the another dht11 sensor. I am sure it will work!!
#include<dht.h>
dht DHT;
#define DHT11_PIN A0
void setup(){
Serial.begin(9600);
}
void loop()
{
DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
delay(1000);
}
Upvotes: 1