Skip to content

Measure temperature/humidity using DHT22 + LCD i2c + Arduino



Hello there,

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 a LCD i2c screen to visualize the measures, check LCD i2c tutorial in case you don’t know how to use it.

And for the temperature I’m using both Celsius and Fahrenheit, you chose what suits you.

DHT22-PinOut

Differrences between DHT11 and DHT22:

DHT11 DHT22
Temperature range 0-50 Ā°C -40 ā€“ 80 Ā°C
Error Ā±2 Ā°C Ā±0.5 Ā°C
Humidity range 20-80% 0-100%
Error Ā±5% Ā±2-5%
Sampling Rate 1Hz 0.5Hz

As you can see the 22 is more accurate and have high range but it reads one value every 2 seconds 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, I didn’t use it because i didn’t see any difference, you can add it if you want but don’t forget that pull-up resistor dissipate more power in case you want to use it in a project using batteries or low consumption circuit…

Wirings:

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

DHT 1

The pin 3 is not connected



Wiring 2: Adding the LCD i2c screen

DHT 2
DHT22 wired with LCD iĀ²c and Arduino UNO

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).

Code 1: Here it’s a direct use with Arduino, the values are shown on the serial monitor

Code 2: Using the LCD iĀ²c, values are shown in Ā°C



Code 3: Using the LCD iĀ²c, values are shown in Ā°F

 

Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

6 thoughts on “Measure temperature/humidity using DHT22 + LCD i2c + Arduino Leave a comment

Leave a Reply

Discover more from SURTR TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading