0
Offline
Newbie
Karma: 0
Posts: 36
Arduino rocks
|
 |
« on: April 06, 2011, 10:28:01 am » |
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 !
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #1 on: April 06, 2011, 11:04:46 am » |
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
Tesla Member
Karma: 71
Posts: 6617
Arduino rocks
|
 |
« Reply #2 on: April 06, 2011, 11:40:17 am » |
Are those Arduinos powered from Vin or Vcc? I suspect the latter as my Uno manages 4.98V from the internal regulator.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9393
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #3 on: April 06, 2011, 01:09:45 pm » |
Or use one external Vref for both Arduino's ..
|
|
|
|
|
Logged
|
|
|
|
|
Cairns - Green Island for Winter
Offline
Full Member
Karma: 2
Posts: 148
|
 |
« Reply #4 on: April 09, 2011, 06:34:35 am » |
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 not Government issues. To stop corruption give them 3 times the normal penalty. Have them agree on first appointment.
|
|
|
|
Sussex UK / CT USA
Offline
Edison Member
Karma: 0
Posts: 1026
Forums forever
|
 |
« Reply #5 on: April 10, 2011, 05:52:54 am » |
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
Newbie
Karma: 0
Posts: 36
Arduino rocks
|
 |
« Reply #6 on: April 13, 2011, 03:44:45 am » |
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
Newbie
Karma: 0
Posts: 36
Arduino rocks
|
 |
« Reply #7 on: April 14, 2011, 08:08:13 am » |
Also with more detailed formula still doesn't working .... after an accurate measurement of sensor input voltage (5.17 V) 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
Newbie
Karma: 0
Posts: 43
Arduino rocks
|
 |
« Reply #8 on: April 25, 2011, 11:49:17 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!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 36
Arduino rocks
|
 |
« Reply #9 on: April 26, 2011, 08:07:43 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!
Hi Jon and thank you for your answer  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
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #10 on: April 26, 2011, 08:41:15 am » |
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
Newbie
Karma: 0
Posts: 36
Arduino rocks
|
 |
« Reply #11 on: April 26, 2011, 08:43:21 am » |
If it's true you solve me a lot of problems :-)
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #12 on: April 26, 2011, 09:25:02 am » |
It's true! See this circuit for a related problem: http://ruggedcircuits.com/html/circuit__13.htmlNote 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
Newbie
Karma: 0
Posts: 36
Arduino rocks
|
 |
« Reply #13 on: April 26, 2011, 09:31:07 am » |
It's true! See this circuit for a related problem: http://ruggedcircuits.com/html/circuit__13.htmlNote 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/SecretVoltmeterBtw: RuggedCircuits your Gadget Shield is awesome ......... 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #14 on: April 26, 2011, 09:36:14 am » |
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
|
|
|
|
|
|