top of page

DHT11 Sensors Temperature and Humidity and i2c LCD - Arduino

In this tutorial we will learn how to use the DHT11 sensor for measuring temperature and humidity and either heat Index.

What Will I Learn ?

In this tutorial we will learn how to use the DHT11 sensor for measuring temperature and humidity and either heat Index. And we will see the value output of the DHT sensors on both the serial monitor and the LCD screen. we are going to use The LCD screen componen with this tutorial you can also print on a serial monitor on the Desktop IDE. Code and circuit diagram are compatible within both sensors. so lets start the procedures.


We need these couples of components in this tutorial,

  • DHT11 Sensor Module

  • 12C LCD Display 2x16

  • Arduino Board

  • Bread Board

  • Jumper Wires

  • Type B USB cable


  • Intermediate

Tutorial Contents

Were going to use the I2C LCD to display the Temperature and Humidity that the DHT11 has captured, I used an Arduino UNO 5V pin to support the DHT11 and the I2C display. DHT22 humidity sensor can be used in place of DHT11 for more accuracy and higher resolution. i made a Circuit diagram on fritzing for you to easily follow the wirings.

Connection of I2c Display to arduino board

  • VCC - 5V

  • GND - GND

  • SCL - A4

  • SDA - A5

Connection of DHT11 sensor module to arduino board

  • VCC - 3.3 V

  • GND - GND

  • DAT - PIN 2 PWM


We are done building the circuit so lets start to set up and make a code for this. we are going to use the arduino ide, to set the sketch for this, if you dont have make sure to download the Arduino IDE for your specific operating system. I’ll leave a link to where you can download this software:

  • After the installation we need to download the DHT11 library for the sensor module Library or you can directly Installed from the Library Manager in Arduino IDE or download on github:

  • We need to download the i2c library To get the i2c 2x16 LCD library download it here: 

When the download is finished open the zip file then copy the folder unzip the folder to your desktop you can rename it as well.

Cut the folder in your desktop then go to your folders then locate the arduino folder>> libraries then paste it there. and now the folder liquidcrystal and DHT11 library is already in the arduino ide libraries.

The first thing we need to do is to define the i2c LCD address i will put here the code of the i2c scanner

LiquidCrystal_I2C lcd(INPUT ADDRESS HERE, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); cut the input address here on the code and put i2c address there.

to do this download the i2c scanner on this link: open it with arduino DEsktop IDE compile then upload it to the board, now click on the serial monitor and get the address of your LCD.

An address before the ! sign is the address of your display. lets say your address is 0x27 replace the input address here with your captured address. so it will become LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

when making a code we need include all the libraries we will be using we have to add the library that we have recently downloaded. #include <DHT.h> for DHT sensor library and #include <LiquidCrystal_I2C.h> for the i2c 2x16 LCD DISPLAY.

#define DHTPIN 2 Define DHT pin this the pin where the sensor pin of the DHT is connected to the digital pin 2 on the arduino board.

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); Input the i2c address that we recently make.

DHT dht; define the uppercase DHT to dht in lowercase to recognized that the lower case is the same as upper case on the same state.

setup() method is ran once at the just after the Arduino is powered up and the loop() method is ran continuously afterwards.

setup() is where you want to do any initialisation steps, and in loop() you want to run the code you want to run over and over again.

lcd.begin(16,2); initializes the LCD 2X16 and specifies the dimensions

lcd.print the iput text word that appears on the serial monitor or lcd display.

delay(2000); 1000 is equals to 1 second timeframe.


#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHTPin 2                        //define DHT pin
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
DHT dht;
void setup() {
  lcd.begin(16,2);                      //initializes the LCD and specifies the dimensions
void loop() {
  float temp = dht.getTemperature();
  float humi = dht.getHumidity();
  lcd.print("Temp: ");
  lcd.print(" C");
  lcd.print("Humi: ");
  lcd.print(" %");

The end result is as shown in the picture.

I hope you enjoy this actitvity if want to learn how arduino works, and how to make a sketch, then maybe this site help you, I was inspired by Mert Arduino and Tech for this wonderful stuff.

Power in Numbers




Project Gallery

bottom of page