Posted on

Interfacing LM35 with Arduino

In many IoT projects, process temperature interlocking is very important. Consider a simple project where we need to turn on a fan/AC when the temperature is above certain degree which act as setpoint. In this kind of projects, a temperature sensor senses the temperature and passes the temperature value to the controller. Then the controller compares the current value of the temperature with setpoint. If the current temperature is above the setpoint then the fan/AC is turned on by the controller. In such projects, it is important to know that how temperature sensor is interfaced with the controller. In this blog, the interfacing LM35 temperature sensor with Arduino is discussed.

LM35 is a temperature sensor out of many other sensors whose output is analog. LM35 is a sensor whose working principle is similar to a diode. Whenever the temperature increases, the voltage across a diode increases at a linear rate. This sensor can be used anywhere to sense the current temperature of any environment. It may help to make some DIY projects which are based on temperature interlocking.

Required components Interfacing LM35

  1. Arduino UNO X 1
  2. LM 35 X 1
  3. USB data cable X 1
  4. Breadboard X1
  5. Jumper cables

Circuit description for Interfacing LM35

The Proteus circuit diagram for interfacing LM35 temperature sensor is shown in Figure 1. Physical connection for interfacing LM35 sensor is shown in Figure 2. The temperature readings from the sensor is shown in Figure 3.

Figure 1: Setup for interfacing LM35.

Arduino UNO has six analog pins. We are going to use A1 pin and that can be connected with the output pin of the LM35. The VCC pin of the LM35 is connected with the 5V supply pin of the Arduino. The ground pin of the LM35 is connected with a ground pin of Arduino Uno.

Code for Interfacing LM35 with Arduino

const int lm35_pin = A1;        /* LM35 O/P pin */

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

void loop() {
  int temp_adc_val;
  float temp_val;
  temp_adc_val = analogRead(lm35_pin);        /* Read Temperature */
  temp_val = (temp_adc_val * 4.88);        /* Convert adc value to equivalent voltage */
  temp_val = (temp_val/10);        /* LM35 gives output of 10 mv per °C */
  Serial.print("Temperature = ");
  Serial.print(temp_val);
  Serial.print(" Degree Celsius\n");
  delay(1000);
}
Figure 2: Physical connection for interfacing LM35 with Arduino
Figure 3: Temperature readings from the LM35 sensor

Conclusion

The circuit will help beginners to make their school/college projects. One can use it to make a project where temperature sensing is achieved by LM35 and things are controlled by Arduino. This project also gives knowledge about how to interface an analog sensor to the Arduino.