Software apps and online services
Please visit https://proteshea.com/process/learn/embedded-systems/display-temp-and-humidity-on-lcd-with-arduino-uno/ for a complete list of materials needed for this project.
In this project, we are going to interface a DHT11 temperature and humidity sensor, and display the data on a 16x2 LCD. If you haven't read Project 9 for the Arduino Uno Rev3, please read that first because this covers how to interface a 16x2 character LCD in 4-bit mode. We will then swap out the 16x2 LCD for a 20x4 LCD to display the humidity and the temperature in Celsius, Fahrenheit, and Kelvin. The DHT11 sensor can be used for a weather station, weather balloon, drone, or greenhouse.16x2 Character LCD
In our previous project, we showed you how to interface a 16x2 LCD to the Uno. You should have pins 4, 6, and 11 - 14 of the LCD connected to Uno pins 2, 3, and 4 - 7, respectively. You can either connect the LCD using a solderless breadboard or the Modulus Canister. An image is shown below with it connected to Modulus.
The 20x4 LCD adds two extra rows and four extra columns per row compared to the 16x2 LCD. Similar to the 16x2, the 20x4 LCD uses the Hitachi controller so the commands and interfaces are the same. It also has the same 16-pin header, allowing you to unplug the 16x2 LCD and plug in the 20x4 without changing any wiring. The only thing we have to change is one line of code, lcd.begin(20, 4), which specifies the columns (first argument) and rows (second argument) of the LCD. An image of the 20x4 LCD is shown below.
There are different types of DHT sensors such as the DHT11, DHT21, DHT22, DHT33, and DHT44. They all measure both temperature and humidity, but the difference lies mostly in their accuracy and sampling rate. For example, we show a side-by-side comparison in the table below of the two most popular DHT sensors, DHT11 and DHT22. The DHT22 has a better accuracy and range, but it has a slower sampling rate, it's bigger in size, and double the cost of the DHT11.
To measure the temperature and humidity, a thermistor and a capacitive humidity sensor are used, respectively. The resistance of a thermistor changes with a change in temperature - as the temperature increases, the resistance decreases. For the humidity sensor, the resistance between the two electrodes changes with a change in humidity. Both of these changes in resistance are measured by the IC on the sensor and sent to the host via a 1-wire interface. Each sample consists of a 40-bit data packet.
We are using a 3-pin DHT11 sensor as shown in the image below. The pins are "+", "OUT", and "-." The sensor can be supplied with both +5Vdc or +3.3Vdc - we'll be supplying +5Vdc to it.
We are mounting the DHT11 sensor to the 2.54mm pitch section of Modulus with a right-angle (R/A) female header, as shown in the image below. Solder the 4-pin R/A female header to the edge of the board. Next, solder a 4-pin male header adjacent to the female header. Once you have the headers soldered on, flip the board over and make a solder bridge between the adjacent pins of the headers.
Wire-wrap the "+" pin to +5Vdc which is any of the pins in column 20 on the 4x26-pin breakout. Then wire-wrap the "-" pin to the GND vector just below the 4x26-pin breakout. Use a 12" F/M jumper to connect the "OUT" pin to pin 8 of the Uno. If you are using a breadboard, a wiring schematic is shown below.
If you haven't mounted the Uno onto the prototyping area of the FuelCan, go ahead and do that. If you are using a breadboard instead of Modulus, place the breadboard in the bottom storage compartment to limit the length of the jumper wires. You'll need to supply +5V and GND to the power and ground rails on the breadboard by using the provided banana jack to test-lead clip cables. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno's receptacle. Power up the FuelCan with the AC-DC power adapter.Software
Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. The first sketch is used with the 16x2 LCD. The second sketch is used with the 20x4 LCD. The DHT11 sensor is sampled every two seconds since sampling faster causes errors.
You'll need the DHT Library to use the DHT functions within the sketch which is available on Arduino's website.