Temperature measurement using LM35

I'm doing a project on beaglebone black and I'm interfacing a LM35 temperature sensor (datasheet) to one of the ADC pins of the beaglebone. As per the Beaglebone datasheets the reference voltage of the inbuilt ADC is 1.8V and it has a resolution of 12 bits. I'm using the below formula for the temperature calculation but I'm getting the wrong values.

$$Temperature = \frac{1.8}{4095} \times (ADC\,Reading) \times 100$$

The ADC reading is 315 and room temperature as measured by the thermometer is 31.2 degree celsius and if I apply the above temperature I get reading as 18.3 centigrade which is not correct.

Not sure where I'm going wrong, I followed this blog to do my experiment.

• Are you certain that you have the correct reference voltage? Apr 6 '14 at 5:59
• Yes , it is 1.8V check the below link learn.adafruit.com/… Apr 6 '14 at 6:05
• 315 is very close to the mV you'd expect from the ADC at 31.2°C. Are you sure it's not already scaled? Apr 6 '14 at 6:32
• I agree with @SpehroPefhany that it's probably already scaled by your software. Otherwise check the voltage at the LM35 terminals (both supply and temp) with a DVM to verify. Apr 6 '14 at 6:35
• What is the vale you are reading from the ADC unmodified: 315? Apr 6 '14 at 6:52

It appears that the reading has already been scaled by the software, since the 315 ADC reading you are seeing is very close to the 312 you'd expect with a room temperature of 31.2°C (which, in turn, seems about 10°C too hot for comfort, but that's just my opinion).

As you've found, you only need to divide the number (which is the mV) by 10.0 (mV/°C) to get the temperature in Celsius.

Just my 10 cents...

LM35 gives you a 10mV per degree centigrade output

You can connect directly LM35 output to BB AINx input

i.e. 45° means 450mV on AINx pin

Since this pin reads values from 0 to 1800 mV in 4096 steps (12bits) you have 2,275 steps per mV , but every single degree means 10mV so you have 22,75 steps per mV ten.

Then you have to divide the ADC reading (cat /blablabla/AINx) by 22,75 to obtain directly the decimal value of celsius degrees using an LM35 directly.

i.e. simple shell test script :

temp='echo "$(cat /sys/devices/platform/omap/tsc/ain1) / 22.75" | bc' echo Temperature is$temp degrees centigrade.

Don't know if this was what you're looking for....

Fred.