Measuring Temperature with Arduino and LM35 Sensor

Learn how to measure temperature using the LM35 sensor with Arduino.

What is an LM35 Sensor?

The LM35 is a precision temperature sensor that provides a voltage output proportional to the temperature. It outputs 10 mV per degree Celsius, with a range of -55ºC to 150ºC.

LM35 Sensor

Price

LM35 sensors are affordable and widely available. They can be purchased for around €0.60 from international sellers.

Electrical Schematic

The pinout of the LM35 consists of two pins for power (VCC and GND) and a middle pin for the temperature signal output. The following is the circuit schematic:

LM35 Circuit Schematic

Assembly Diagram

The LM35 can be easily assembled on a breadboard as shown in the following diagram:

LM35 Assembly Diagram

Code Example

The following code reads the temperature using the LM35 sensor, converting the analog input into degrees Celsius:


const int sensorPin = A0;

void setup() {
    Serial.begin(9600);
}

void loop() {
    int value = analogRead(sensorPin);
    float millivolts = (value / 1023.0) * 5000;
    float celsius = millivolts / 10; 
    Serial.print(celsius);
    Serial.println(" C");
    delay(1000);
}
            

Important Notes

Ensure the LM35 is powered correctly and avoid exposing it to temperatures outside its operating range (-55ºC to 150ºC).