Introduction: Measure Temperature Using Lm35 and Arduino
The lm35 is an analog linear temperature sensor. This means that the output voltage is proportional to the temperature. The output voltage rises by 10mv for every 1 degree Celsius rise in temperature. The Arduino can read input from 0-5v. The Arduino stores this as a 10bit number(0-1023). The method that i am going to use now can be used to measure temperature from 2 degree Celsius to the maximum temperature that your lm35 can measure. I will make another article on how we can measure temperatures below that soon.
Step 1: Making the Connections
The lm35 that i used has the ground pin and the Vs pin interchanged compared to the Texas Instruments one, the data sheet for which is commonly available. If you have interchanged the pins while connecting the sensor it will get hot so you'll know if its incorrect.
connect the Vs pin to the 5v pin on the Arduino and ground to one of the 2 ground pins on the power rail. Connect the Vout pin to one of the analog pin, A0 in my case.
Another thing i noticed is that the temperature that you get is not reliable if you connect many jumper cables together to make the wire long.
Step 2: The Program
Here is the sketch:
temp=analogRead(temppin); // Reading data from the sensor.This voltage is stored as a 10bit number
/* 5*temp/1024 is to convert the 10 bit number to a voltage reading.
This is multiplied by 1000 to convert it to millivolt.
We then divide it by 10 beacuse each degree rise results in a 10 millivolt increase.
delay(500);// This is because we dont want a continuous stream of data
Upload the sketch to your Arduino
Step 3: Check the Temperature
Open the serial monitor and check the temperature. The temperature reading will change every 0.5 seconds.
We have a be nice policy.
Please be positive and constructive.