Build a digital thermometer using a temperature sensor

Building a digital thermometer using a temperature sensor is a fun and educational electronics project. In this example, we will use a popular temperature sensor called the LM35, which provides an analog voltage output that corresponds to the temperature. We’ll interface it with an Arduino to display the temperature in degrees Celsius on an LCD screen. Here’s how to create this digital thermometer:

Components you’ll need:

Arduino board (e.g., Arduino Uno)
LM35 temperature sensor
16×2 LCD display (compatible with the Hitachi HD44780 driver)
Potentiometer (10k ohms) for LCD contrast adjustment
Breadboard and jumper wires
USB cable for power and programming
Arduino IDE (installed on your computer)
Circuit Connections:

Connect the LM35 temperature sensor as follows:

LM35 Vcc (Pin 1) to Arduino 5V
LM35 Vout (Pin 2) to Arduino Analog Input A0
LM35 GND (Pin 3) to Arduino GND
Connect the 16×2 LCD display as follows:

LCD VSS to Arduino GND
LCD VDD to Arduino 5V
LCD V0 (LCD contrast) to the center terminal of the potentiometer
Connect one end of the potentiometer to Arduino 5V
Connect the other end of the potentiometer to Arduino GND
LCD RS to Arduino digital Pin 12
LCD RW to Arduino GND
LCD E to Arduino digital Pin 11
LCD D4 to Arduino digital Pin 5
LCD D5 to Arduino digital Pin 4
LCD D6 to Arduino digital Pin 3
LCD D7 to Arduino digital Pin 2
LCD A (anode) to Arduino 5V
LCD K (cathode) to Arduino GND
Make sure all the connections are secure and double-check for any loose wires.

Arduino Code:

Upload the following Arduino code to your Arduino board using the Arduino IDE:


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin = A0; // LM35 analog output connected to A0 pin
float temperature; // Stores temperature value

void setup() {
lcd.begin(16, 2); // Initialize the LCD

void loop() {
int sensorValue = analogRead(sensorPin); // Read analog value from LM35
float voltage = (sensorValue / 1024.0) * 5.0; // Convert to voltage
temperature = (voltage – 0.5) * 100.0; // Convert to Celsius

lcd.clear(); // Clear the LCD screen
lcd.setCursor(0, 0); // Set cursor to the first row
lcd.print(“Temp: “);
lcd.print(” C”);

delay(1000); // Update every 1 second
This code reads the analog output from the LM35 temperature sensor, converts it to Celsius, and displays the temperature on the LCD screen. Make sure you have the “LiquidCrystal” library installed in your Arduino IDE.


Connect your Arduino to your computer using the USB cable.
Open the Arduino IDE, select the appropriate board and port under the “Tools” menu.
Upload the code to your Arduino.
After uploading, you should see the temperature displayed on the LCD screen in degrees Celsius, updating every second.
Your digital thermometer using the LM35 temperature sensor and Arduino is now complete. You can further customize it by adding Fahrenheit conversion or other features, depending on your preferences.