Pages: [1] 2   Go Down
Author Topic: Clarification about LM35*  (Read 2319 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there.

I need a clarification about these temperature sensor  smiley-confuse

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 !
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your "well-known formula":

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
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12178
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are those Arduinos powered from Vin or Vcc?  I suspect the latter as my Uno manages 4.98V from the internal regulator.
Logged

[ I won't respond to messages, use the forum please ]

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13705
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or use one external Vref for both Arduino's ..
Logged

Rob Tillaart

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

Cairns - Green Island for Winter
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Back on the old board you will find a prety lengthy discusson/argumentabout this .
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
Logged

Governments should do what they were designed to do only.
Manage the larger issues best done by Government.
My Family and my Property are no

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your "well-known formula":

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 !
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also with more detailed formula still doesn't working ....
after an accurate measurement of sensor input voltage (5.17 V)

Code:
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.

What do you think about this ?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

Hi Jon and thank you for your answer  smiley

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 ?
Logged

Global Moderator
The Netherlands
Offline Offline
Sr. Member
*****
Karma: 1
Posts: 287
don't panic...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If it's true you solve me a lot of problems :-)
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
https://code.google.com/p/tinkerit/wiki/SecretVoltmeter


Btw: RuggedCircuits your Gadget Shield is awesome .........  smiley-cool
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!  That link you found looks useful too....we'll add that to the web page as an alternative.

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

Pages: [1] 2   Go Up
Jump to: