LM35 temperature sensor
LM35 temperature sensor
Components Required:
2. LM35 temperature sensor
3. Connecting wires
LM35 temperature sensor Basics:
LM35 is a low cost sensor and it could be easily available to purchase. It has a very important feature of linear output. The output voltage varies by 10mV in response to every oC rise/fall in ambient temperature. So if the output of LM35 is 220mv/0.22V the temperature will be 22°C. So if room temperature is 32°C then the output of LM35 will be 320mv i.e. 0.32V.
LM35 voltage conversion to temperature formula derivation for ardiuno
Arduino analog pins can measure up-to +5 volts OR the voltage on which it is working normally +5 volts. Arduino analog pin resolution is 1023 starting from 0. On +5 volts input it counts to 1023. Lm35 max voltage output is 1500mV( At 150 degree centigrade). 1500mV is equal to 1500/1000 = 1.5 volts. So Lm35 at max outputs 1.5 voltage. Arduino analog pin count for 1.5 volts equals to (1.5 / 5)*1023 = 306.9 . At +5 volts its 1023 and at 1.5 volts its 306.9. ew Arduino-Lm35 Resolution = 306.9 / 150 = 2.046 . Now if arduino analog pin counts 2.046 its equal to 1 degree change in centigrade/Celsius temperature of LM35.
Interfacing LM35 with Arduino UNO:
Interfacing this sensor is very easy. We need to connect VCC and ground pins. Middle one is output pin which could be connected any of the analog input pin. Here it is connected to pin A0.
Programming:
First we need to do a float type of variable declaration to store final value of temperature. In
void setup() we just need to initialize serial port. Now in
void loop() we need to read the analog output value of sensor and convert it into a oC value
float temp; //variable to store temperature in degree Celsius
void setup()
{
Serial.begin(9600);
}
void loop()
{
temp = analogRead(A0); // output value of sensor
temp=temp/2.046; // convert in oC
Serial.print("Temperature =");
Serial.print(temp);
Serial.println("oC ");
delay(1000);
}
No comments: