Home Code SHT21 sensor data displayed on an LCD shield

SHT21 sensor data displayed on an LCD shield

by shedboy71

In a previous example we connected a SHT21 temperature and humidity sensor to an Arduino – http://www.arduinolearning.com/code/sht21-humidity-and-temperature-sensor-example.php. This was a bit basic as the data was sent via the serial port, so lets add an LCD to display the temperature and humidity readings, there are plenty to choose from but we picked the LCD and keypad shield. Its cheap and cheerful and since there were only 2 readings to worry about and this has 2 lines that should do nicely.

Here is a picture of what you will make, I soldered headers on the LCD keypad shield for connecting to the sensor breakout using dupont type cables, just to make it a bit easier.



SHT21 and LCDKeypad shield

SHT21 and LCDKeypad shield


Needs the SHT21 library installed – https://github.com/elechouse/SHT21_Arduino

Again most of the work is done in a couple of libraries, the LCD and SHt21 ones so not a great deal of code required for this example

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <SHT2x.h>
#include <LiquidCrystal.h>

//setup for the LCD keypad shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() 
  // put your setup code here, to run once:
  //line 1 - temperature
  lcd.print("Temp: ");
  //line 2 - humidity
  lcd.print("Humidity: ");

void loop() 
  // put your main code here, to run repeatedly:



Some links to the bits required, you can pick up the sensor for about $7 and the shield for $5 easily. So not too expensive, there are cheaper sensors we'll cover them later.

Humidity Sensor – SHT21 Breakout Board

1602 LCD Keypad Shield for Arduino Duemilanove UNO MEGA2560 MEGA1280


You may also like