Interface LM35 temperature sensor with Arduino

What is an LM35 temperature sensor?

It is a precision centigrade temperature sensor that is used to measure the temperature of its surrounding. The output voltage of LM35 varies linearly with the temperature in centigrade. It has an advantage over the temperature sensor calibrated in Kelvin, as the user does not require any calculation to convert Kelvin to Celsius. It does not require any external calibration and has an accuracy of ±0.25°C at room temperature and accuracy of ±0.75°C for a range of -50°C to 150°C. It is mainly used in power supplies, battery management systems and HVAC.

Pin configuration of the LM35 temperature sensor

LM35 temperature sensor pin diagram

Features of the LM35 temperature sensor

  • The operating voltage is 4 to 30 volts.
  • The operating current is <60mA.
  • It has a linear scale factor of +10mV/C°.
  • It provides a low-impedance output, 0.1 ohms for 1mA load.
  • It is a low-cost integrated-circuit due to wafer-level trimming.

Components needed

  • Arduino UNO
  • LM35 temperature sensor
  • Breadboard
  • Jumper wires

Pin connections of LM35 with Arduino

  • Connect the VCC pin of the sensor to the 5v pin of the Arduino UNO.
  • Connect the GND pin of the sensor to the GND pin of the Arduino UNO.
  • Connect the OUT pin of the sensor to the A0 pin of the Arduino UNO.

Circuit diagram of an LM35 temperature sensor with Arduino UNO

LM35 temperature sensor circuit diagram

Arduino code for the LM35 temperature sensor

int tempPin = 2;
//Define a pin for OUT pin of the sensor
 
void setup()
{
Serial.begin(9600);
//Set baud rate for serial communication
}
void loop()
{
int senValue = analogRead(tempPin);
//Get values from sensor using analogRead() function
float value = (senValue/1024.0)*5000;//Convert the read values to mV
float cel = value/10;
//Convert mV to celsius
float far = (cel*9)/5 + 32;
//Convert celsius to fahrenheit
Serial.print("TEMPRATURE IN CELSIUS: ");
Serial.print(cel);
//Print celsius values on the serial monitor
Serial.print("*C");
Serial.println();
delay(100);
Serial.print("TEMPRATURE IN FAHRENHEIT:");
Serial.print(far);
//Print fahrenhiet values on the serial monitor
Serial.print("*F");
Serial.println();
delay(100);
}

Leave a Reply