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.


Differrences between DHT11 and 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…


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

DHT22 wired with LCD i²c and Arduino UNO


  • 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


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

%d bloggers like this: