Arduino Nano - LM35 Temperature Sensor LCD

This tutorial instructs you how to use Arduino Nano to read the temperature from an LM35 sensor and then display it on an LCD 16x2 I2C.

Arduino Nano LM35 Temperature Sensor LCD

Hardware Preparation

1×Arduino Nano
1×USB A to Mini-B USB cable
1×LM35 Temperature Sensor
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino Nano
1×(Recommended) Screw Terminal Adapter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you. We appreciate your support.

Overview of LM35 Temperature Sensor and LCD I2C

If you are unfamiliar with the LM35 Temperature Sensor and LCD I2C (including pinout, how it works, and how to program), the following tutorials can help you learn:

Wiring Diagram

The wiring diagram between Arduino Nano and LM35 Temperature Sensor LCD

This image is created using Fritzing. Click to enlarge image

Arduino Nano Code - LM35 Temperature Sensor - LCD I2C

/* * This Arduino Nano code was developed by * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * */ #include <LiquidCrystal_I2C.h> // LCD I2C library #define ADC_VREF_mV 5000.0 // in millivolt #define ADC_RESOLUTION 1024.0 #define PIN_LM35 A0 // pin connected to LM35 temperature sensor LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD I2C address 0x27 (from DIYables LCD), 16 column and 2 rows void setup() { Serial.begin(9600); lcd.init(); // Initialize the LCD I2C display lcd.backlight(); // open the backlight } void loop() { int adcVal = analogRead(PIN_LM35); // convert the ADC value to voltage in millivolt float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION); // convert the voltage to the temperature in Celsius float temperature_C = milliVolt / 10; float temperature_F = temperature_C * 9 / 5 + 32; // convert Celsius to Fahrenheit lcd.clear(); lcd.setCursor(0, 0); // start to print at the first row lcd.print(temperature_C); // print the temperature in Celsius lcd.print("°C"); lcd.setCursor(0, 1); // start to print at the second row lcd.print(temperature_F); // print the temperature in Fahrenheit lcd.print("°F"); // print the temperature to Serial Monitor Serial.print(temperature_C); Serial.print("°C ~ "); Serial.print(temperature_F); Serial.println("°F"); delay(500); }

Detailed Instructions

  • Click to the Libraries icon on the left bar of the Arduino IDE.
  • Search for “LiquidCrystal I2C” and locate the LiquidCrystal_I2C library by Frank de Brabander.
  • Then, click the Install button to install the library.
Arduino Nano LiquidCrystal I2C library
  • Copy the code and open it in the Arduino IDE.
  • Click the Upload button on the Arduino IDE to compile and upload the code to the Arduino Nano.
  • Position the sensor in hot and cold water, or hold it in your hand.
  • Check out the result on the LCD and Serial Monitor.


The address of the LCD may differ depending on the manufacturer. In our code, we used 0x27 as specified by DIYables.

Video Tutorial


  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!