Go Down

Topic: DHT11 code problem (Read 260 times) previous topic - next topic

sex92toso

I am, apart from being new in this Arduino world, getting struggle to see some reasonable values from this sensor. I am getting for both temperature and humidity a 0.00 value.

Here is the simple code needed for it, hope someone can understand this.

Code: [Select]
#include <dht.h>

#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;
 
void setup(){
 
  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor
 
}
 
void loop(){
 
    DHT.read11(dht_apin);
   
    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature);
    Serial.println("C  ");
   
    delay(5000);

}


I would like to ask also if there is any difference between taking an analog Pin or digital in this case. I am here using analog as I supposed that digital will only give a 0 or a 1 while analog gives possible values between 0 and 1023

Go Up