Arduino interfacing with DHT11 sensor and LCD

Interface Arduino with DHT11 sensor and LCD circuit

This topic shows how to interface Arduino UNO board with DHT11 digital humidity and temperature sensor where the measure humidity and temperature are displayed on 1602 LCD screen.

DHT11 Sensor technical specifications:

  • Humidity Range: 20-90% RH
  • Humidity Accuracy: ±5% RH
  • Temperature Range: 0-50 °C
  • Temperature Accuracy: ±2 °C
  • Operating Voltage: 3V to 5.5V
  • Resolution = 1

Hardware Required:

  • Arduino board
  • DHT11 (RHT01) sensor
  • 1602 LCD screen
  • 4.7K ohm resistor
  • 10K ohm variable resistor
  • 330 ohm resistor
  • Breadboard
  • Jumper wires

Arduino + DHT11 + LCD connection circuit:
Our interfacing circuit diagram is shown below.

Arduino DHT11 sensor and LCD circuit

As show in the circuit schematic the DHT11 sensor has 4 pins: VCC (+5V), Data, NC(not connected pin) and GND (from left to right). A pull-up resistor should be added to the data pin with a value between 4.7K and 10K.
The 10K variable resistor is used to control the contrast of the LCD screen and the 330 ohm resistor supplies the LCD backlight LED.

Arduino code:
In this interfacing I used DHT sensors library (DHT11, DHT21 and DHT22) from Adafruit. This library initiates the DHT11 sensor and reads the values of the humidity and temperature.
Since the DHT11 sensor resolution is 1, the values of the humidity and temperature are stored in two variables with type byte (8-bit unsigned), I named them RH (for the humidity) and Temp (for the temperature).
The values of the humidity and temperature needs to be displayed on the LCD after the reading, and for that I used two character arrays named: temperature (char temperature[] = “Temp = 00.0 C “;) and humidity (char humidity[] = “RH = 00.0 % “;). Humidity and temperature values are copied to the previous arrays before displaying it. For example the temperature value is copied to the array temperature as follows:
temperature[7] = Temp / 10 + 48;
This line means the 7th character of the array is equal to the tens of temperature value
temperature[8] = Temp % 10 + 48;  (Temp%10 equals to the remainder of Temp/10)
and this line means the 8th character of the array is equal to the ones of temperature value. For example if the temperature value is 42 ==> 42 / 10 = 4 and 42 % 10 = 2.
The number 48 is used to convert decimal numbers to AscII because the LCD works with AscII format.
The line temperature[11] = 223; means adding the degree symbol (°).

Arduino + DHT11 simulation video:
The video below shows simulation of the example using Proteus.

Downloads:
Adafruit library for DHT series (after extracting put the folder named DHT in the library folder of Arduino):
Download

To be able to simulate this example, Proteus needs the Arduino library which can be downloaded from the link below. After extracting the files (ARDUINO.IDX and ARDUINO.LIB) put it in the Library folder (ex: C:\Program Files\Labcenter Electronics\Proteus 8 Professional\LIBRARY):
Download

Arduino + DHT11 + LCD Proteus simulation file download:
Download

9 comments

        1. OK.
          Replace: char temperature[] = “Temp = 00.0 C “; by: char temperature[] = “Temp = 00.0 F “; — this is just for ‘F’ letter.

          Replace: byte Temp = dht.readTemperature(); by: int Temp = (dht.readTemperature() * 1.8 + 32) * 10;

          Replace the following 2 lines:
          temperature[7] = Temp / 10 + 48;
          temperature[8] = Temp % 10 + 48;

          by the following 7 lines:
          if(Temp >= 1000)
          temperature[6] = ‘1’;
          else
          temperature[6] = ‘ ‘;
          temperature[7] = (Temp / 100)% 10 + 48;
          temperature[8] = (Temp / 10) % 10 + 48;
          temperature[10] = Temp % 10 + 48;

          1. I really thank you very much I appreciate what you did because I learned a little more about the codes and how to write them Thanks.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.