what is conversion system of LM35 (temperature sensor) in Celsius?
35,397
Solution 1
the truth always lies within the datasheets:
- http://www.ti.com/lit/ds/symlink/lm35.pdf on how to get the data from the LM35 ;
- http://atmel.com/Images/doc8161.pdf on how to use the Atmega ADC.
The Atmega ADC: Analog to Digital Converter
Your Atmega is powered by 5V, and the datasheet of the Atmega states that its ADC has a definition of 1024 values (i.e. 10bits). So in your formula, 5/1024
is representing each voltage step represented by a bit:
0.0000V -> 0b0000000000
0.0048V -> 0b0000000001
...
5.0000V -> 0b1000000000
Getting value out of the LM35
If you read the application notes in the LM35 datasheet, you'll find the following formula:
Vout=10mV/°C
if you're binding the LM35 with a 200ohms resistor. So if you use the rule of three, you'll get:
Vout=0.01/°C
°C=Vout/0.01
°C=Vout/0.01
°C=Vout*100
HTH
Solution 2
for Arduinos;
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
Author by
shajib0o
Updated on January 31, 2020Comments
-
shajib0o over 4 years
I see formula like
temp = (5*val*100/1024)
Can anyone tell me the details of this formula?
-
shajib0o almost 10 yearswhy there is 11 bit for voltage representation? :@zmo
-
zmo almost 10 yearsbecause it should be 8 bits, it's been a typo when I wrote my answer :-)
-
zmo almost 9 yearsthanks to a rejected edit, just noticed that I was wrong: this is indeed 10bits, as the datasheet specs it, and the voltage representation is on 10 bits. Aside from that detail, what I say stays right.