You can use an Arduino to monitor the air temperature by using an LM35 temperature sensor

The LM35 is an ideal temperature sensor for measuring ambient temperature. It provides a linear output proportional to the temperature, with 0 V corresponding to 0 degrees C and an output voltage change of 10 mV for each degree C change. LM35s are easier to use than thermistors and thermocouples because they are so linear and require no signal conditioning. 

The output of an LM35 can be connected directly to a Arduino analog input. Because the Arduino analog-to-digital converter (ADC) has a resolution of 1024 bits, and the reference voltage is 5 V, the equation used to calculate the temperature from the ADC value is:

temp = ((5.0 * analogRead(TemperaturePin)) / 1024) * 100.0

To display the temperature, we will use a liquid crystal display (LCD). 


The purpose of this experiment to build a temperature monitor using an LM35, a 16x2 LCD, and an Arduino.

Hardware Required

  • 1 x Arduino Mega2560
  • 1 x LCD 
  • 1 x 5 kohm potentiometer
  • 1 x breadboard
  • 1 x LM35 temperature sensor
  • 1 x 1k ohm resistor
  • Female connectors
  • jumper wires

Wiring Diagram

Circuit Diagram
Circuit Diagram

Connect the components as shown in the figure above. A 1 kohm resistr is connected between the LM35 output and GND to limit the current without affecting the output voltage. 

LCD Pins
LCD Pins

The LCD is connected to the Arduino as shown below. The middle terminal of the potentiometer is connected to pin 3 of the LCD to change the brightness of the LCD backlight. The other two pins of the potentiometer are connected to 5 V and GND. Enable is connected to Arduino pin 9 of Arduino and RS is connected to Arduino pin 8. RW is connected to ground. 

DB4-----> pin4







The program uses the LiquidCrystal.h library to write data to the display. In the loop(), the value of the sensor output is continually read, converted to degrees C, then displayed on the LCD. 

                    #include    //arduino lcd library

LiquidCrystal lcd(8,9,4,5,6,7);   //defining lcd pins

int value=0;            //initializing variables
float volts=0.0;      
float temp=0.0;      
float tempF=0.0;

void setup()
  pinMode(3,INPUT);      //setting arduino pin3 as input
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  lcd.begin(16,2);      // set up the LCD's number of columns and rows

void loop()
  value=analogRead(A0);          //read from A0
  volts=(value/1024.0)*5.0;      //conversion to volts
  temp= volts*100.0;             //conversion to temp Celsius
  tempF=temp*9/5+32;             //conversion to temp Fahrenheit

//display temp no lcd

  Serial.print("temperature= "); 
  lcd.print("TEMP= ");
  lcd.print(" C");
  lcd.print("TEMP= ");
  lcd.print(" F");

  Download Code  




  • aabacc 2016-02-17

    Hello, can you explain the limiting resistor after the LM35 output. From the specs,; the chip specs states it takes a max of .1 ma (I think that what it means) so I don’t think there is that much current going to the Arduino?


  • Sounak Nandy 2016-03-24

    Is the code for Arduino UNO same for Arduino ATMega 2560

  • Nakul Nair 2017-05-31

    What adc value will we be a getting for 25 degree c. How is it derived please explain

    • Robert Keim 2017-05-31

      In the code you can see the steps needed to convert from ADC reading to degrees C:

        value=analogRead(A0);      //read from A0
        volts=(value/1024.0)*5.0;    //conversion to volts
        temp= volts*100.0;        //conversion to temp Celsius

      If you work backwards, you will find that 25 degrees C corresponds to an ADC reading of about 51.