Connect LM35 analog temperature sensor to Arduino

The LM35 is an inexpensive, precision Centigrade temperature sensor made by Texas Instruments. It provides an output voltage that is linearly proportional to the Centigrade temperature and is, therefore, very easy to use with the Arduino.

The sensor does not require any external calibration or trimming to provide accuracies of ±0.5°C at room temperature and ±1°C over the −50°C to +155°C temperature range.

One of the downsides of the sensor is that it requires a negative bias voltage to read negative temperatures. So if that is needed for your project, I recommend using the DS18B20 or TMP36 instead. The TMP36 by Analog Devices is very similar to the LM35 and can read temperatures from -40°C to 125°C without any external components.

The pinout of the sensor:

Note that pin 1 (+VS) is the leftmost pin when the flat side of the sensor (with the text printed on it) is facing towards you.

Pin1: +VS  - Positive power supply pin (4 – 30 V)
Pin2: Vout - Temperature sensor analog output
Pin3: GND  - Device ground pin

Source code of Arduino sketch:

#define sensorPin A0

void setup() {
  // Begin serial communication at a baud rate of 9600:
  Serial.begin(9600);

  // Set the reference voltage to the built-in 1.1V reference:
  analogReference(INTERNAL);
}
void loop() {
  // Get a reading from the temperature sensor:
  int reading = analogRead(sensorPin);

  // Convert the reading into voltage:
  float voltage = reading * (1100 / 1024.0);

  // Convert the voltage into the temperature in degree Celsius:
  float temperature = voltage / 10;

  // Print the temperature in the Serial Monitor:
  Serial.print(temperature);
  Serial.print(" \xC2\xB0"); // shows degree symbol
  Serial.println("C");
  delay(1000); // wait a second between readings
}