Temperature Sensor LM35 with Arduino | applied electronics engineering

Latest

Temperature Sensor LM35 with Arduino

By Applied Electronics - Sunday, January 29, 2017 No Comments
In this tutorial we show how to measure temperature using LM35 IC and Arduino. LM35 is a temperature sensor with three pins and looks like a voltage regulator IC. Temperature sensor IC can be used in robotics or for measuring temperature of a room etc.

Arduino is a flexible learning microcontroller board to which you can connect various sensors and output and input devices.

In this arduino tutorial we show how you can build easily a thermostat using LM35 IC, bunch of LEDs, bunch of resistors and arduino. We connect the center pin of LM35 to the analog pin A1 of the arduino. The other two pins are connected to power and ground respectively. At the other side, we connect 5 LEDs(different colors if you have) to pin 2 to pin 6 and ground them via individual 220Ohm resistors. The circuit diagram is shown below.



The LM35 outputs analog voltage proportional to the temperature it senses from its center. To be specific, for each degree Celsius it outputs 10 mV. For example for room temperature of 25 degree Celsius the analog voltage is 250 mV from its center pin output. The ADC internal to Arduino microcontroller converts this voltage amplitude to digital amplitudes which can be then be used to light up LEDs. If the temperature is low, no LED will turn ON, and the more hotter it gets the more LEDs will turn ON.

See the following video for proteus simulation:



Program Code or Sketch for this is below:

int LED [5] = {2, 3, 4, 5, 6};
int Tsensor = A1;

void setup(){
Serial.begin(9600);
for (int i = 0; i < 5; i++){
pinMode(LED[i], OUTPUT);
}

}
void loop(){

int val = analogRead(Tsensor);
Serial.println(val);

for (int i = 0; i < 5; i++){
digitalWrite(LED[i], LOW);
}
if (val > 40 && val < 45){ // 20 - 22 C
digitalWrite( LED[0], HIGH);
} else if (val > 45 && val < 49){ // 22 - 24 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
} else if (val > 49 && val < 53){ // 24 - 26 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
digitalWrite( LED[2], HIGH);
} else if (val > 53 && val < 57){ // 26 - 28 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
digitalWrite( LED[2], HIGH);
digitalWrite( LED[3], HIGH);
} else if (val > 57){ // Over 28 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
digitalWrite( LED[2], HIGH);
digitalWrite( LED[3], HIGH);
digitalWrite( LED[4], HIGH);
}
delay(100);
}

This tutorial showed you how you can use temperature sensor LM35 with arduino. See similar projects How to control LED using LDR using Arduino.

No Comment to " Temperature Sensor LM35 with Arduino "