LCD Temp and humidity display

Display Temperature and Humidity on 16×2 LCD using Arduino

In this post, we are going to build a digital thermometer and hygrometer with LCD readout using the DHT11 digital temperature and humidity sensor module and a 16×2 LCD (with HD44780 chipset) using and arduino microcontroller board.

The DHT11 is a relatively affordable package that is used to take digital temperature and humidity readings. The sensor module is versatile in that it is in a neat package ready to plug in to a microcontroller project using only three pins, one for the data, one for the 5Vsupply and one for the ground.

The communications is a one wire propriety protocol that outputs a 40 bit data packet when requested by the controller device. The protocol used is not is not addressable so if multiple sensors are required a separate pin will be needed per sensor.

We covered the DHT11 sensor module in a previous post here and also covered the how to setup a 16×2 LCD display in last post here. In this post we will combine our two previous posts to read the DHT11 sensor and display the temperature sensor to the LCD display.

 

Components to make the 16×2 LCD DHT11 temperature and humidity project

  • DHT11 temperature and humidity sensor
  • 16×2 LCD Shield (with Hitachi HD44780 chipset or equivalent)
  • Arduino UNO (or compatible board)
  • Computer
  • USB cable
  • Dupont hook up wire

 

HD44780 LCD and DHT11 sensor wiring to an Arduino board

Wiring the LCD to the microcontroller board uses 6 pins as we are using the LCD in 4 bit mode. We need to use pins 4,5,6,7,8,9 of the arduino. The temperature and huidity sensor will use 1 pin which we have selected as pin 2, the other two pins are for the 5V supply and ground. So in total for this project we are required to use 7 pins.

 

LCD, DHT11 and arduino pinout

 

 

Programming the microcontroller

When setting up the microcontroller, we need to include the LiquidCrystal.h and DHT11.h libraries. The LiquidCrystal.h library is preinstalled in the Arduino IDE but the DHT11.h library needs to be installed by going into the “library manager” and searching for the “DHT sensor library” then installing it.

Once the libraries are included, we need to setup the LCD by setting the LiquidCrystal lcd variables to (9, 8, 4,5,6,7) then setting the LCD size to 16×2.

After the devices are setup we read the DHT11 sensor and input the temperature and humidity readings in the float variables (t) and (h) respectively.
Then the (t) and (h) variables are written to the LCD, (t) on line 0 and (h) on line 1.
We introduce a 2000mS delay time to wait for the DHT11 sensor to take a reading.
Then the program is looped to continuously read the DHT11 sensor and output the readings to the LCD display.

program code

 

Adding a 16×2 LCD (HD44780) display to a microcontroller and displaying temperature and humidity readings from the DHT11 temperature and humidity sensor demonstrates how we can use several components together to make a useful project. These devices combined with an arduino platform make it very easy for anyone from an electronics hobbiest or artist to a professional electronics engineer to make and build programmable electronics projects.

I hope this tutorial has been useful to you.

If you liked it please share it with a Friend !

Subscribe Now !

Receive updates and new information straight to your inbox.