lm35 temperature sensor arduino lcdlm35 temperature sensor arduino

Reading the environment temperature is one of the most important task for the majority of the applications. We are going to use LM35 Temperature sensor with Arduino in this example. Even in embedded systems, temperature sensors are one of the most basic and most important sensors used in wide variety of products. Some of the most important products which requires the temperature sensors are

  • Weather station
  • Incubator Temperature Control
  • Water Heating System
  • Baby Warmer for biomedical applications

Above mentioned applications are some of the more than 100 products where we need some kind of temperature sensors to get the temperature measurements.

LM35 is one of the temperature sensor which is very popular and very simple to use. It gives the voltages on its output pin which be proportional to the temperature it sense from it’s environment.

Here are the steps You need to follow for using LM35 temperature sensor with arduino uno.

Total Time: 15 minutes

Grab all the parts required

LM35, Arduino Uno

Connect LM35 to Arduino

Connect the Analog Output pin of LM35 with A0 pin of Arduino UNO.

lm35 temperature sensor arduino lcd

Open Arduino IDE and start coding

For reading the temperature values first of all you need to Decide how you want to display the output? In our case we are going to display the temperature on Serial Terminal. So we need to initialize the Serial port with desired baudrate. Which, in our case is 9600. After that in loop() function we need to read the analog input

Upload the Sketch to Arduino UNO

Once you are done coding you are good to upload the sketch to your arduino uno board. Connect the USB cable to the board and plug in into your computer. Now select the serial port from tools menu and after that upload the sketch

Open the serial monitor and Verify the output

Once uploaded, all you have to do is to open the serial terminal and check the output.


Now Let’s create a simulation file to test and validate our code first. We will create the simulation in Proteus 7.6. The simulation is very similar to the actual circuit which we will build later. But for now, The simulation circuit is here for us to test our code. The LM35 Arduino and 16×2 Character LCD is used as our main components and most of the power connections, including the 16×2 LCD contrast potentiometer is omitted and not included in the simulation because that is not as necessary to test our simulation. So for the sake of simplicity we will neglect this in the simulation.

Here is how our simulation file looks like,

LM35 Arduino Simulation results

Here are the pins of the Arduino which we are using for external interfacing of the LCD as well as LM35

// Pin Definitions
 define LCD_PIN_RS    7
 define LCD_PIN_E    6
 define LCD_PIN_DB4    2
 define LCD_PIN_DB5    3
 define LCD_PIN_DB6    4
 define LCD_PIN_DB7    5
 define LM35_PIN_VOUT    A3
Code language: JavaScript (javascript)

Few words about LM35

LM35 is a temperature sensor which provides analog output voltages proportional to the temperature. LM35 can measure the temperature from the range -55C to 150C centigrade. It looks very similar to the 3 pin transistor visually. It has 3 pins two for the power connections and middle pin is used to read the analog voltages to measure the required temperature.

LM35 Pin mapping


Here is the complete code for the simulation

for compelete blog
#include <LiquidCrystal.h>
// Pin Definitions
#define LCD_PIN_RS 7
#define LCD_PIN_E 6
#define LCD_PIN_DB4 2
#define LCD_PIN_DB5 3
#define LCD_PIN_DB6 4
#define LCD_PIN_DB7 5
#define LM35_PIN_VOUT A3
float getTempC(byte nSamples)
int val = 0;
for (byte i =0 ; i < nSamples ; i++ ){
val += analogRead(LM35_PIN_VOUT);
return (5.0 * val * 100.0) / 1024.0 / nSamples;
float convertToF(float tempInC){
return ((tempInC*1.8)+32); // Converting Celcius to Fahrenheit
void setup() {
while (!Serial) ; // wait for serial port to connect. Needed for native USB
// set up the LCD's number of columns and rows
lcd.begin(16, 2);
lcd.print(F("LM35 Reading"));
void loop() {
float lm35TempC = getTempC(10);
float lm35TempF = convertToF(lm35TempC);
Serial.print(F("Temp: "));
Serial.print(F("C, "));
Serial.println(F("F, "));
lcd.print(F("C, "));
lcd.print("F" );


[1]“How to wire LM35, LCD 16×2 to Arduino Uno,” Circuito.io, 2021. https://www.circuito.io/app?components=512,11021,333429,341099 (accessed Jan. 14, 2021).

By Abdul Rehman

My name is Abdul Rehman and I love to do Reasearch in Embedded Systems, Artificial Intelligence, Computer Vision and Engineering related fields. With 10+ years of experience in Research and Development field in Embedded systems I touched lot of technologies including Web development, and Mobile Application development. Now with the help of Social Presence, I like to share my knowledge and to document everything I learned and still learning.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.