In this article, we are presenting a tutorial on how to interface LM35 and Arduino along with its program. Once we successfully interface arduino and lm35, we will go on to build a temperature display using arduino and a 16×2 LCD module which constantly monitors temperature around the measurement field/range of LM35 and displays the same on LCD module. So lets get to building the project!
LM35 is an analog, linear temperature sensor whose output voltage varies linearly with change in temperature. LM35 is three terminal linear temperature sensor from National semiconductors. It can measure temperature from-55 degree celsius to +150 degree celsius. The voltage output of the LM35 increases 10mV per degree Celsius rise in temperature. LM35 can be operated from a 5V supply and the stand by current is less than 60uA. The pin out of LM35 is shown in the figure below.
So that’s all info you need about LM35 for this particular temperature display project using arduino uno. So lets get to LM35 temperature sensor interfacing with arduino!
We are using Arduino Uno as our board and LM35 can be connected to arduino as shown in circuit diagram.
Note:- LM35 is an analog temperature sensor. This means the output of LM35 is an analog signal. Microcontrollers dont accept analog signals as their input directly. We need to convert this analog output signal to digital before we can feed it to a microcontroller’s input. For this purpose, we can use an ADC( Analog to Digital Converter).If we are using a basic microcontroller like 8051, we need to use an external ADC to convert analog output from LM35 to digital. We then feed the output of ADC ( converted digital value) to input of 8051. But modern day boards like Arduino and most modern day micro controllers come with inbuilt ADC. Our arduino uno has an in built 10 bit ADC (6 channel). We can make use of this in built ADC of arduino to convert the analog output of LM35 to digital output. Since Arduino uno has a 6 channel inbuilt ADC, there are 6 analog input pins numbered from A0 to A5. Connect analog out of LM35 to any of these analog input pins of arduino.
LM35 and Arduino – Circuit Diagram
Connect LM35 to Arduino uno as shown in circuit diagram. The +5v for LM35 can be taken from the +5v out pin of arduino uno. Also the ground pin of LM35 can be connected to GND pin of arduino uno. Connect Vout (the analog out of LM35) to any of the analog input pin of arduino uno. In this circuit diagram, we have connected Vout of LM35 to A1 of arduino.
Note:- LM35 is available in the market in 3 series variations – LM35A, LM35C and LM35D series. The main difference between these 3 versions of LM35 IC are in their range of temperature measurements. The LM35D series is designed to measure from 0 degree Celsius to 100 degree Celsius, where as the LM35A series is designed to measure a wider range of -55 degree Celsius to 155 degree Celsius. The LM35C series is designed to measure from -40 degree Celsius to 110 degree Celsius.
In our LM35 arduino example, we are using the LM35Dz sensor- which falls under LM35D series. So our min-max range of temperature measurement is 0 degree Celsius to 100 degree Celsius.
The Program – LM35 and Arduino Interfacing
const int sensor=A1; // Assigning analog pin A1 to variable 'sensor' float tempc; //variable to store temperature in degree Celsius float tempf; //variable to store temperature in Fahreinheit float vout; //temporary variable to hold sensor reading void setup() { pinMode(sensor,INPUT); // Configuring pin A1 as input Serial.begin(9600); } void loop() { vout=analogRead(sensor); vout=(vout*500)/1023; tempc=vout; // Storing value in Degree Celsius tempf=(vout*1.8)+32; // Converting to Fahrenheit Serial.print("in DegreeC="); Serial.print("\t"); Serial.print(tempc); Serial.println(); Serial.print("in Fahrenheit="); Serial.print("\t"); Serial.print(tempf); Serial.println(); delay(1000); //Delay of 1 second for ease of viewing }
So that’s the arduino lm35 code for reading temperature and displaying in degree Celsius and Fahrenheit. The program is self explanatory.
The Output Screenshot of Serial Monitor
Okay! We have learned the LM35 temperature sensor interfacing with arduino. If you have any doubts regarding this part, ask in comments section.
Temperature Display on 16×2 LCD Module – using Arduino and lM35
Now lets go on to add a 16×2 LCD display with LM35 and Arduino – interface and lets display the temperature values on this LCD display (instead of serial monitor). So we are going to build none other than a stand alone temperature display using arduino.
Note:- If you are a beginner, read our tutorial on Interfacing LCD Module to Arduino before you try your hand at this project of LM35 and Arduino with a 16×2 LCD display.
Circuit Diagram – LM35 and Arduino – Temperature Display on 16×2 LCD
Okay! So that’s the circuit diagram to build an Arduino LM35 temperature sensor with LCD display. The arduino program for the circuit is given below.
The Program
#include<LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int sensor=A1; // Assigning analog pin A1 to variable 'sensor' float tempc; //variable to store temperature in degree Celsius float tempf; //variable to store temperature in Fahreinheit float vout; //temporary variable to hold sensor reading void setup() { pinMode(sensor,INPUT); // Configuring pin A1 as input Serial.begin(9600); lcd.begin(16,2); delay(500); } void loop() { vout=analogRead(sensor); vout=(vout*500)/1023; tempc=vout; // Storing value in Degree Celsius tempf=(vout*1.8)+32; // Converting to Fahrenheit lcd.setCursor(0,0); lcd.print("in DegreeC= "); lcd.print(tempc); lcd.setCursor(0,1); lcd.print("in Fahrenheit="); lcd.print(tempf); delay(1000); //Delay of 1 second for ease of viewing in serial monitor }
Okay! The program is very simple and self explanatory, if you have a basic idea of arduino sketches and you already learned how to interface arduino and lcd module.
Some people would like to use 7 Segment display to display temperature measured using LM35 and Arduino. so our next section explains, how to build a system using LM35 and Arduino to display temperature on a 7 segment display.
First of all, learn our tutorial on Interfacing Arduino and 7 Segment Display – which clearly explains interfacing different types of seven segment displays to arduino and how to display different numeral digits/characters on them. For displaying temperature upto 3 digit values (100 degree Celsius or higher upto 999) with corresponding unit (Celsius of Fahrenheit), its good to choose a 4 Digit 7 Segment Display unit.
19 Comments
hey help me to control motor speed with lm35 and arduino
Sir, if i want to add a buzzer to alert if temperature goes above set point.suppose if (temperature>30)then buzzer beep.please help me.
using above program i made temperature sensor. it showing around 500 degree C which is wrong it should show around 25 to 30 degree. i have made all connection right and i kept small wire for connecting sensor and arduino.please suggest some solution as possible.
hi my project is working but nothing is showing up on the lcd screen
learn to build a temp with LM-35 lcd include
Hello sir , thank you for the project
when I read the temperature from the lcd it seems to work perfectly but when i heat the envirement of the sensor it goes crazy form 25 to 7 to 0 to 30 etc
do you have any idea why ?
Please check the connections properly. The ‘ground’ could be floating in your case. Please make sure all connections are according to circuit diagram. All grounds should connect together at a common point.
In the second line of the
VOID LOOP() {} ,
u have used a conversion by multiplying by 500 and dividing by 1024. Why ?
Hey, don’t bother ! Got it .
Isn’t it like…
convert digital data into analog by multiplying by 5000 and dividing by 1024
AND THEN, each degree celsius is for 10mV and hence we divide again by 10. ?
Yes – You are right! 🙂
How to send message to the phone telling about the temperature
what is meant by serial.begin(9600)
It starts the serial connection between the computer and arduino.
Hey, don’t bother ! Got it .
Isn’t it like…
convert digital data into analog by multiplying by 5000 and dividing by 1024
AND THEN, each degree celsius is for 10mV and hence we divide again by 10. ?
As i am a fresher to the electronics field , i want to develop a digital thermometer for my hobby projects . For the above posted article , i need 5 Lm35 senser to be placed and corresponding temperature should be measured at different 7 Seg LCD display.Please help in doing this
Hi how do I add a red led for too warm , green for lukewarm and blue for cold to this code?
When the wire becomes longer, the readings from LM35 get distorted.
In 2014, I used a circuit to reduce the distortion. I have couple of pictures of the circuit, I don’t know how to post them here
@Manir – Thanks for sharing this info. Will be useful for all readers. You can send the circuit you built to avoid distortion here – info@circuitstoday.com and if its good enough, we shall publish.
ok need to make this project to work i build circuit in to breadboard but need to install the code in pc so i van download arduino uno r3