How to Integrate a Temperature Sensor Circuit to an LCD
In this project, we will go over how we can build a temperature sensor circuit and integrate it to an LCD so that we can get a readout of the temperature on the LCD.
In previous projects with temperature sensor circuits, we built the circuit and then got a readout on the computer that we programmed the circuit with. In this project, we take it a step further. Instead of getting a readout on the computer, we will connect the circuit so that we can get a readout on an LCD display. This mimics a more real-life-like electronic product which you would see on the market.
To build this circuit, we will need 3 main components. We will need a temperature sensor IC. The one we will use in this project is a LM34 temperature sensor IC. We will need an LCD display. The type we will use is the popular HD44780 LCD. And we will need a microcontroller to get the readout from the sensor IC and then transfer the readout to the LCD>
To be successful building this circuit, you should know how to connect temperature sensor ICs and how to wire a HD44780 to an arduino.
To learn how to wire a LM34 temperature sensor IC to an arduino, see How to Build a LM34 Tempreature Sensor Circuit.
To learn how to wire an HD44780 LCD to an arduino, see How to Display Text on an HD44780 LCD with an Arduino.
Once you know how to connect these two devices, then interfacing them together is relatively easy and straightforward.
Knowing how to interface LCDs with other electronic devices is a valuable, valuable skill, because this is how most electronic consumer devices work in the industry.
- LM34 Temperature Sensor IC
- HD44780 LCD
- 10KΩ potentiometer
Of course you'll need a whole bunch of jumper wires to wire all the connections.
But for this circuit, really, only these 4 main components are necessary.
The circuit which we will build to interface a temperature sensor to an LCD for LCD readout is shown below.
Connections of the HD44780 LCD to an Arduino
|LCD Pin||Function of LCD Pin||Arduino Pin|
|4||RS (Register Select Pin)||12|
|5||R/W (Read/Write Pin)||Gnd|
|6||E (Clock Enable Pin)||11|
|15||Anode (for backlight)||5V|
|16||Cathode (for backlight)||Gnd|
Connections of the LM34 to an Arduino
|LM34 Pin||Function of Pin||Connects to Arduino Pin...|
What makes this circuit easy to build is that the HD44780 LCD only uses the digital pins of the arduino board. The LM34 temperature sensor uses the analog side of the arduino, pin A0. So they don't conflict or need to use the same pins. This makes it relatively easy.
The HD44780 uses the digital pins because it's purely a digital device. The LM34 connects to an analog pin because it gives an analog output. The arduino then uses its onboard ADC (analog to digital converter) to convert this temperature to a digital output and measure it.
Once we have this configured with this physical setup, all we need is the code to output the temperature reading to the LCD.
//In my example, I use a 20x4 LCD, thus it has 4 rows and 20 columns
//If you use another LCD, type in the appropriate rows and columns below
int outputpin= 0;
const int numRows= 4;
const int numCols= 20;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int rawvoltage= analogRead(outputpin);
float millivolts= (rawvoltage/1024.0) * 5000;
float fahrenheit= millivolts/10;
The first line of code includes the LiquidCrystal library. With this library, we can utilize functions (such as lcd.print) that make coding this project much easier.
The second block of code is used for defining pin connections. Since the output pin of the temperature sensor connects to analog pin 0, it is assigned to 0. In our project, since we are using a 20x4 LCD, we set numRows to 4 and numCols to 20.
The third line of code defines all the pin connections from the LCD to the arduino board. The LCD are connected to digital pins 12, 11, 5, 4, 3, 2 of the arduino board.
The fourth block of code defines a serial connection and where the cursor on the LCD should begin. This marks where new text will appear when we write to the LCD. Since we want the word temperature to stay constant throughout the whole program, we place it in the setup() function rather than the loop() function. The setup function defines permanent setup. The loop function defines constantly changing data, since it's always in a loop throughout the program.
The fifth block of code is our actual loop for our circuit. In this block, we read the analog voltage from the temperature sensor IC from the output pin. We convert this voltage into temperature fahrenheit. We then print out this temperature to the lcd using the lcd.print function. We then take a 5-second delay. This way, the temperature IC reads and updates the temperature every 5 seconds. You can change the delay to suit how often you want the temperature updated. But for all practical purposes, a user shouldn't need the temperature updated more often than that.
And this is how a temperature sensor interfaced to an LCD works.
How to Drive a 7 Segment LED Display with an Arduno
How to Connect and Read a Keypad with an Arduino
How to Build a Motion Detector Circuit with an Arduino
How to Build a Motion Sensor Light Circuit with an Arduino
How to Build a Hall Effect Sensor Circuit
How to Build a Motion Detector Circuit
How to Build a Vibration Detector Circuit