In this tutorial we’ll try to measure temperature and humidity using the DHT22, DHT22 and DHT11 are famous sensors used a lot for measuring temperature and humidity, they are pretty much the same, simple to interface and simple to use.
I also add to the project an LCD i2c screen to visualize the measures, LCD i2c tutorial
And for the temperature I’m using both Celsius and Farenheit you chose what suits you.
Differrences between DHT11 and DHT22:
|Temperature range||0-50 °C||-40 – 80 °C|
|Error||±2 °C||±0.5 °C|
As you can see the 22 is more accurate and have high range but it reads one value every second unlike the 11 that reads every second, but accuracy is more important.
In this tutorial I’m using the 4 pins version of the DHT22, unlike my DHT11 tutorial where I used the 3 pin version of the DHT11, both versions are the same because the other pin is not used, also they add a pull-up resistor, you cann add one if you want, I didn’t use it because i didn’t see any difference, you can add it if you want but don’t forget that a pull-up resistor dissipate more power in case you want to use it in a project using batteries or low consumption circuit…
Wiring 1: wiring directly to Arduino to visualize the measures on the Arduino IDE monitor
N.B: In case you want to add a pull-up resistor you can leave this wiring as is it then add a 10k resistor with 5v from arduino and pin 2 of the DHT22
The pin 3 is not connected
Wiring 2: Adding the LCD i2c screen
Codes and libraries:
DHT library: works for both DHT11 and 22 needs only a little change in the code you can see it in codes, download here (Just download the zip file, then in arduino IDE add it and it will install quickly)
LCD i2c library: Newliquidcrystal Download here
Codes : Download here all used codes, then chose what suits your project (contains, printing in C and F in serial monitor, printing in C on LCD and printing in F on LCD).
Automation and Electrical Engineer, Electronics amateur trying to share my little projects.