Go Down

### Topic: Clarification about LM35* (Read 4488 times)previous topic - next topic

#### un1x

##### Apr 06, 2011, 05:28 pm
Hi there.

I need a clarification about these temperature sensor  :~

I'm working with 2 identical sensor on 2 different Arduino, but with the well-known formula
temp = (5 * analogRead(0) * 100.0) / 1024.0
I get different values for the 2 sensors. I know there's a 0.5 ° error in the these values, but sometimes it's wrong of 1.5 ° or more.

So my answer: I assumed that "5" in the formula is the current voltage the LM35DZ is powered, but on real boards it's never exactly 5 V.
With the tester I've checked current voltages are:
Arduino 1 = 4.81 V
Arduino 2 = 5.17 V

Do you think that changing these values I'll get a "more real" value or "5" is the correct number ?

Thanks !

#### RuggedCircuits

#1
##### Apr 06, 2011, 06:04 pm

temp = (5 * analogRead(0) * 100.0) / 1024.0

needs to replace "5" with the actual board voltage, 4.81V, 5.17V, etc. So it is not surprising that you get a large temperature error if you have a large reference voltage error.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

#### MarkT

#2
##### Apr 06, 2011, 06:40 pm
Are those Arduinos powered from Vin or Vcc?  I suspect the latter as my Uno manages 4.98V from the internal regulator.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### robtillaart

#3
##### Apr 06, 2011, 08:09 pm
Or use one external Vref for both Arduino's ..
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### tytower

#4
##### Apr 09, 2011, 01:34 pm
Look for my posts probably 12 to 18 months ago

The datasheet for arduino and the device datasheet together actually prove the variation can be up to two degrees out.
The problem is with arduino is  the 5 Volts is as you say usually less . Trying to get an accurate measure of the exact voltage at the time is not as simple as Vref . It does not work . I spent weeks looking for an answer and gave up on the project .

I had sensors in freezers radioing readings each 60 secs but they were not accurate enough for my needs
Still looking though. The full programs are there too

#### tkbyd

#5
##### Apr 10, 2011, 12:52 pm
You can get around all of the problems discussed above simply by moving to the Dallas temperature sensors, aka the "1-Wire" chips, or DS1820 and cousins.

#### un1x

#6
##### Apr 13, 2011, 10:44 am

temp = (5 * analogRead(0) * 100.0) / 1024.0

needs to replace "5" with the actual board voltage, 4.81V, 5.17V, etc. So it is not surprising that you get a large temperature error if you have a large reference voltage error.

That's it .. Thanks !

#### un1x

#7
##### Apr 14, 2011, 03:08 pm
Also with more detailed formula still doesn't working ....
after an accurate measurement of sensor input voltage (5.17 V)

Code: [Select]
`temp = (5.17 * analogRead(0) * 100.0) / 1024.0`

temperature sampled = approx 23°
real temperature = approx 21.5°

Maybe I can go on with more sampling procedures trying to find the relative error ..
or the absolute one if exists.

#### jondecker76

#8
##### Apr 26, 2011, 06:49 am
I'm working with the LM35 in a project of mine also (a solar water heater controller).  It reads 5 LM35 sensors (ambient, panel temp, tank temp, pump outlet temp, and tank inlet temp).

I noticed this variation as well, and a made a calibrate function (accessed with a DR Robot LCD Keypad shield). What it does is lets me "calibrate" by comparing an LM35 reading with a known reading..  I enter the correct reading and it computes and stores a multiplier to use (multiplier = actual_temp / lm35_temp )... Then I add it into the formula to be:

temp = ((5.0 * multiplier) * analogRead(0) * 100.0) / 1024.0

One of the reasons I had to implement this multiplier calibration technique is that each LM35 has different length leads running to them (from about 5' to around 20'),  so each one needs calibrated individually to compensate for voltage drop, etc.  In the end it seems to work pretty well!

#### un1x

#9
##### Apr 26, 2011, 03:07 pm

I'm working with the LM35 in a project of mine also (a solar water heater controller).  It reads 5 LM35 sensors (ambient, panel temp, tank temp, pump outlet temp, and tank inlet temp).

I noticed this variation as well, and a made a calibrate function (accessed with a DR Robot LCD Keypad shield). What it does is lets me "calibrate" by comparing an LM35 reading with a known reading..  I enter the correct reading and it computes and stores a multiplier to use (multiplier = actual_temp / lm35_temp )... Then I add it into the formula to be:

temp = ((5.0 * multiplier) * analogRead(0) * 100.0) / 1024.0

One of the reasons I had to implement this multiplier calibration technique is that each LM35 has different length leads running to them (from about 5' to around 20'),  so each one needs calibrated individually to compensate for voltage drop, etc.  In the end it seems to work pretty well!

It's similar like my idea, but I can't understand how you can calculate the multiplier.
You try to get the temp value from the temp value. I assume you use the old temperature value and the old known temperature to calculate the multiplier for the new one. Is it right ?

#### Yot

#10
##### Apr 26, 2011, 03:41 pm
You know an arduino can measure it's own Vcc (~5V)? 'arduino hidden functions' gives info from google. The trick is to measure the internal bandgap voltage with Vcc as reference and 'reverse' the calculation.

Jeroen.

#### un1x

#11
##### Apr 26, 2011, 03:43 pm
If it's true you solve me a lot of problems :-)

#### RuggedCircuits

#12
##### Apr 26, 2011, 04:25 pm
It's true! See this circuit for a related problem:

http://ruggedcircuits.com/html/circuit__13.html

Note at the bottom that there are references to how an Arduino can measure its own voltage by using the built-in 1.1V bandgap voltage.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

#### un1x

#13
##### Apr 26, 2011, 04:31 pm

It's true! See this circuit for a related problem:

http://ruggedcircuits.com/html/circuit__13.html

Note at the bottom that there are references to how an Arduino can measure its own voltage by using the built-in 1.1V bandgap voltage.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

Thanks for your reply ....... I've also found this code, seems to work pretty good: