LM35 (temperature sensor) interface with Arduino
ARDUINO

Temperature Sensor


Description

The LM35 is a precision analog temperature sensor integrated circuit. It is commonly used to measure temperature in various electronic applications. The LM35 sensor produces an output voltage that is linearly proportional to the temperature in Celsius. It's a popular choice for temperature measurement due to its simplicity and accuracy.


Sensor Details

The LM35DZ is a linear temperature sensor that comes directly calibrated in Celsius. The analog output is directly proportional to the temperature in Celsius: 10 mV per degrees Celsius rise in temperature. 

This sensor is very similar with the LM335 (calibrated in Kelvin) and with the LM34 (calibrated in Fahrenheit).

 

To use the LM35 temperature sensor, you typically connect its pins to the power supply, ground, and an analog input of a microcontroller or ADC. The voltage output of the LM35 can then be converted into a temperature reading using a simple linear equation. For example, if the LM35 outputs 250 mV at a certain temperature, the temperature can be calculated using the formula:

Temperature (°C) = (Voltage - 0.5) * 100

It's important to note that the LM35 sensor measures temperature relative to the local ground, so it's essential to ensure proper grounding for accurate readings.

                                               LM35DZ

Communication protocol

analog ouput

Power supply range

4 to 30 V

Temperature range

-55 to 150ºC

Accuracy

+/-0.5ºC (at 25ºC)

Interface with Arduino

analogRead()

 

 


Wiring Details

Connections:

Connect the LM35's GND pin to the Arduino's GND.

Connect the LM35's VCC pin to the Arduino's 5V.

Connect the LM35's OUT pin to an analog input pin(A0) on the Arduino.


Circuit Image
Circuit Code
                                        
                                            

 

const int lm35Pin = A0;  // Analog input pin connected to LM35 OUT pin

 

void setup() {

  Serial.begin(9600);  // Initialize serial communication

}

 

void loop() {

  int sensorValue = analogRead(lm35Pin);  // Read the analog value from LM35

  float voltage = sensorValue * (5.0 / 1024.0);  // Convert to voltage (assuming 5V reference)

  float temperatureC = (voltage - 0.5) * 100.0;  // Convert to temperature in Celsius

 

  Serial.print("Analog Value: ");

  Serial.print(sensorValue);

  Serial.print(", Voltage: ");

  Serial.print(voltage);

  Serial.print("V, Temperature: ");

  Serial.print(temperatureC);

  Serial.println("°C");

 

  delay(1000);  // Delay for a second before taking the next reading

}