Temperature and humidity for Arduino

posted in: Arduino, Guides | 0

In this short guide, I will share my experience reading temperature and humidity value from a DHT22 sensor that i bought on Adafruit! This sensor needs a 4.7K – 10K resistor, you will use as a pullup from the data pin to VCC that is provided in the linked product.





The shematics are made with awesome tool that is Fritzing.

And photo of my setup with Arduino Yun:


.In order to interact easily with the sensor I strongly recomend you to use this library developped by Adafruit. Put the library files in your source and don’t forget to include the .hpp in your code before using.

Here is the sample code from the DHT library:

If you upload and test the code you’ll be able to receive on your Serial port the sensors data. Remember that calling readHumidity() and readTemperature() may be really time consuming.

In order to understand what is going on in the library, I suggest you to read this source code.

Edit: an awesome tutorial by Adafruit itself is already available here.


Leave a Reply