The dht11 humidity sensor is an economic way to sense the humidity of the air in arduino projects, and what is better, you can skip the stores that sells them sticked in a small piece of pcb, and cost ~6€/$, and instead buy them bulk in ebay half of the price.
Once you’ve got your sensor you’ve to connect it to your arduino, all you need is to connect the GND and VCC legs to corresponding pins in your arduino, and then choose one digital pin for the data line of the sensor. The data pin in the dht11 is which is next to the VCC pin, the other pin is simply not connected to anything.
The protocol that the sensor uses to send the data is not very standard, but in the following datasheet you can find the details and timings to use to effectively communicate with it:
Now is time for the code. I’ve borrowed it from the sheepdogguides guides similar article, but cleaned all the unnecessary text and hold the good explanation comments. Grab it from the following link:
Open it with your arduino IDE, change the ‘dht_dpin’ definition in case you’re using other pin than digital 14 (also known as analog 0), and press upload. The code will be compiled without errors and uploaded to the board in seconds. Now open the Serial Monitor and you should see this:
You have to know that the sensor doesn’t send the decimal part of humidity and temperature readings, because the resolution for both measures is 1.0 unit (1ºC and 1%RH).