ARDUINO TEMPERATURE SENSOR LM35

536,769

138

108

Published

Introduction: ARDUINO TEMPERATURE SENSOR LM35

Now make your own temperature sensor by Arduino and LM35 Sensor
You required following parts
1-ARDUINO BOARD ANY VERSION
2-LM35 TEMPERATURE SENSOR
3-USB CABLE
4-COMPUTER WITH ARDUINO SOFTWERE

MAKE THE CONNECTION AS SHOWN IN IMAGE AND UPLOAD THE FOLLOWING CODE ON ARDUINO BOARD.




int val;
int tempPin = 1;

void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
float farh = (cel*9)/5 + 32;

Serial.print("TEMPRATURE = ");
Serial.print(cel);
Serial.print("*C");
Serial.println();
delay(1000);

/* uncomment this to get temperature in farenhite
Serial.print("TEMPRATURE = ");
Serial.print(farh);
Serial.print("*F");
Serial.println();


*/
}








NOW SEE THE SERIAL MONITOR IN THE ARDUINO SOFTWERE ,
ITS DONE.

VISIT https://www.facebook.com/SparkingElectronics FOR MORE PROJECTS
;)
:)


5 People Made This Project!

Recommendations

  • Planter Challenge

    Planter Challenge
  • Woodworking Contest

    Woodworking Contest
  • Make it Move Contest

    Make it Move Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

108 Comments

We can get value magic number 0.48828125 from following expression:

(SUPPLY_VOLTAGE x 1000 / 1024) / 10 where SUPPLY_VOLTAGE is 5.0V (the voltage used to power LM35)

1024 is 2^10, value where the analog value can be represented by ATmega (cmiiw) or the maximum value it can be represented is 1023. The actual voltage obtained by VOLTAGE_GET / 1024.

1000 is used to change the unit from V to mV

10 is constant. Each 10 mV is directly proportional to 1 Celcius.

By doing simple math: (5.0 * 1000 / 1024) / 10 = 0.48828125

6 replies

Sorry for asking this but what is the magic number you refer to about? What is the importance of it

I think he meant the calibration value. instead of doing all the computation , just get the value from the sensor and multiply it with that value

Hi Please can you tell me if I was to run this program through a Attiny85 on 4.5 volts what formula would I need to use to get the correct results?

you can substitute the SUPPLY_VOLTAGE part which result in

(SUPPLY_VOLTAGE x 1000 / 1024) / 10 = (4.5 x 1000 / 1024) / 10 =

0.439453125

the supply voltage doesn't really matter , i think the analog to digital converter matters though, coz see we can even power the LM35 with a 20 v power supply, if we do that and still read the analog value from arduino, your equation will not hold,

Indeed the supply voltage can ranging from +35V to -0.2V. Well, I got the equation from the LM35 datasheet and never done things outside the datasheet.

I m getting d output as 132.34*C .....in ds pattern nly but not as 23*C n all...wat crctns can I make ????

3 replies

Don't keep the length of sensor pin wire (A0- to lm35) long..
kepp it as short as possible

Hi,

It is short, actually I have inserted the output pin of LM35 directly into the board. Same high readings,+140 degrees. Any idea why?

just check the wiring once again ...
see the picture and connect exactly as shown in image

Mine even hotter

TEMPRATURE = 499.02*C

I made it.

I was trying to put date and time next to the temp so that I can do some analytics on the data. Can someone please help me with the code ? Thanks

the output values are not making ant sense when i kept the sensor in different climatic conditions.they are printing the same values

Very easy, I recieved temperature in F on the serial output. Now I want to output the script to a multi digit LED Dispaly.

instructions are useful but can i connect this project with ni labview?

I have seen lot of people commenting they are getting improper reading let me give you some basic description of LM35 Temperature Sensor

Well LM35 is a linear temperature sensor whose output voltage is proportional to degree centigrade. LM35's output is 10mv/Degree C which means for every degree rise in temperature the output of LM35 will rise by 10mv. 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.

So if you are not getting proper reading then check the output voltage of the sensor is it proportional to the room temperature as explained above? If so check the code that you have typed.