Lesson 12 LM35 Temperature Sensor

Share for us


LM35 is a temperature sensor produced by national semiconductor. It has very high operational accuracy and wide operating range. With small size, low cost and reliability, LM35 is widely applied in engineering. Since it uses internal compensation, so the output can begin with 0℃. LM35 has many different packages. Under normal temperature, the LM35 requires no additional calibration to  reach the accuracy of plus or minus 1/4 ℃. The power supply mode can be classified as single power source and positive and negative double power supply. Its pins are as shown below. Under positive and negative dual power supply mode, it can measure negative temperature. Under single power supply mode and 25℃, the quiescent current is about 50μA and has wide operation voltage. It can work between 4 to 20V, thus  save electricity.


– 1* SunFounder Uno board (or SunFounder Mega2560 board)

– 1*Breadboard

– 1*USB data cable

– 1*LM35 Temperature Sensor

– 1* LCD1602

– 1*Potentiometer

– Several jumper wires

Experimental Principle

The output voltage of the LM35 is proportional to Celsius temperature. When placed in 0℃ ambient temperature, it will output 0V. As the ambient temperature increases by 1℃, its output voltage will increase 10mV. The calculation formula is as follows

Experimental Procedures

Step 1: Build the circuit

The schematic diagram

Step 2: Program (Please refer to the example code in LEARN -> Get Tutorials on our website)

Step 3: Compile the code

Step 4: Upload the sketch to the SunFounder Uno board

Now, you can see the current temperature displayed on the LCD1602.


//LM35 output voltage has a linear relation with the Celsius temperature, output of 0 v when 0 ℃,
//every increase 1 ℃, the output voltage increase 10 mv
#define lmPin A0 //LM35 attach to
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(4, 6, 10, 11, 12, 13);float tem = 0;
long lmVal = 0;void setup()
  lcd.begin(16, 2); // set up the LCD’s number of columns and rows:
void loop()
  lmVal = analogRead(lmPin);
  tem = (lmVal * 0.0048828125 * 100);//5/1024=0.0048828125;1000/10=100
  lcd.setCursor(5,0); //place the cursor on 5 column,0 row
  lcd.print(“LM35″); //print”LM35”
  lcd.setCursor(0,1); //place the cursor on 0 column,1 row
  lcd.print(“Tem= “); //print”Tem= “
  lcd.setCursor(5,1); //place the cursor on 5 column,1 row
  lcd.print(tem); //print tem
  lcd.print(char(223));//print the unit” ℃ “
  lcd.print(” C”);