Arduino UNO R4 - DHT11 - LCD

We will learn to program the Arduino UNO R4 to read temperature and humidity from the DHT11 module and show them on an LCD I2C display.

Arduino UNO R4 DHT11 LCD I2C

Hardware Preparation

1×Arduino UNO R4 WiFi
1×Arduino UNO R4 Minima (Alternatively)
1×USB Cable Type-C
1×DHT11 module
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino UNO R4
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Optional) Transparent Acrylic Enclosure For Arduino Uno

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you. We appreciate your support.

Overview of DHT11 and LCD

Learn about the DHT11 sensor and LCD, including their pinout, functions, and programming in these tutorials:

Wiring Diagram

The wiring diagram between Arduino UNO R4 DHT11 LCD

This image is created using Fritzing. Click to enlarge image

Arduino UNO R4 Code - DHT11 Sensor - LCD I2C

/* * This Arduino UNO R4 code was developed by * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * */ #include <LiquidCrystal_I2C.h> #include <DHT.h> #define DHT11_PIN 2 // The Arduino Uno R4 pin connected to DHT11 module LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27 (from DIYables LCD), 16 column and 2 rows DHT dht11(DHT11_PIN, DHT11); void setup() { dht11.begin(); // initialize the sensor lcd.init(); // initialize the lcd lcd.backlight(); // open the backlight } void loop() { delay(2000); // wait a few seconds between measurements float humi = dht11.readHumidity(); // read humidity float tempC = dht11.readTemperature(); // read temperature lcd.clear(); // check if any reads failed if (isnan(humi) || isnan(tempC)) { lcd.setCursor(0, 0); lcd.print("Failed"); } else { lcd.setCursor(0, 0); // start to print at the first row lcd.print("Temp: "); lcd.print(tempC); // print the temperature lcd.print((char)223); // print ° character lcd.print("C"); lcd.setCursor(0, 1); // start to print at the second row lcd.print("Humi: "); lcd.print(humi); // print the humidity lcd.print("%"); } }


The LCD I2C address can differ based on the manufacturer. In our code, we used the address 0x27 as specified by the manufacturer DIYables.

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Connect the Arduino Uno R4 to the DHT11 module and LCD I2C according to the provided diagram.
  • Connect the Arduino Uno R4 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • Click on the Libraries icon on the left sidebar of the Arduino IDE.
  • Type "DHT" in the search box and locate the DHT sensor library from Adafruit.
  • Press the Install button to add the library.
Arduino UNO R4 DHT sensor library
  • You will need to install additional library dependencies.
  • Click the Install All button to install all library dependencies.
Arduino UNO R4 Adafruit Unified sensor library
  • Look for "LiquidCrystal I2C," then choose the LiquidCrystal_I2C library by Frank de Brabander.
  • Click the Install button to add the LiquidCrystal_I2C library.
Arduino UNO R4 LiquidCrystal I2C library
  • Copy the code above and open it with Arduino IDE
  • Click the Upload button in Arduino IDE to send the code to Arduino UNO R4
  • Change the temperature around the sensor to be hotter or colder
  • Check the result on the LCD screen

If the LCD shows nothing, please check Troubleshooting on LCD I2C.

Video Tutorial


  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!