Tag Archives: humidity sensor

Arduino Micro and temperature+humidity sensor DHT11

Today is sensor day, so I’ve managed to get the [amazon &title=DHT11&text=DHT11] working:

Wire it like that:
([amazon &title=DHT11&text=DHT11] -> Arduino Micro )

  • Pin 1 (orange cable) to 5V
  • Pin 2 (yellow cable) to GND
  • Pin 3 – not needed
  • Pin 4 (yellow again -.-) to A0

Use the following code I’ve found here:

#include <dht.h>

#define dht_dpin A0 //no ; here. Set equal to channel sensor is on

dht DHT;

void setup(){
  Serial.begin(9600);
  delay(300);//Let system settle
  Serial.println("Humidity and temperaturenn");
  delay(700);//Wait rest of 1000ms recommended delay before
  //accessing sensor
}//end "setup()"

void loop(){
  //This is the "heart" of the program.
  DHT.read11(dht_dpin);

    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature); 
    Serial.println("C  ");
  delay(800);//Don't try to access too frequently... in theory
  //should be once per two seconds, fastest,
  //but seems to work after 0.8 second.
}// end loop()

Getting you a result like that:

It doesn’t seem to be very accurate, but that’s expectable rated by its low price (<2€)