Pages: [1]   Go Down
Author Topic: Temp sensor  (Read 2190 times)
0 Members and 1 Guest are viewing this topic.
Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm using two  LM35 temperature sensors and posting their values to Pachube.  The inside one works fine .  The temp sensor outside won't go below 32 degrees.  I have pulled the outside one in and it eventually measures room temp correctly.  
They are are rated -55 to 150 C http://www.national.com/mpf/LM/LM35.html#Overview .
Why won't it go below 32 degrees outside?

Cheers.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have some calculation in your code that doesn't go negative? Maybe some calculation bottoms out at 0 C, then gets converted to F ?

Post your code and someone here will take a look.
« Last Edit: January 04, 2010, 11:28:23 pm by TBAr » Logged

CH
Offline Offline
God Member
*****
Karma: 19
Posts: 704
Book Writer "Arduino Praxiseinstieg"
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you configure your LM35 to use the full temperature range?

See the circuit for full range from the datasheet.



You need to add a resistor (R1) in order to use negative output voltages.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And remember that Arduinos ADC can not handle negative voltages, so you need to do some level shifting as well !!!
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is my code
Code:
void WeatherOut()
{
  inPin = 5;
for(i = 0;i<=7;i++) // gets 8 samples of temperature
 {
 samples[i]= ( 5.0 * analogRead(inPin) * 100.0) / 1024.0;
 inVal = inVal + samples[i];
 }
  inVal = inVal/8.0; // better precision
  t = ((inVal * 9)/ 5 + 32);    
Serial.print("Weather out = ");  
Serial.println(t);
Serial.println(" ");
Serial.println("---------------------------");
Serial.println(" ");
  inVal = 0;        //reset variable
  x=t;
  itoa(t,temp_val,10);
  place="Out";
}
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is not a sw problem, but hw. LM35's output is 10mV / C and starts from zero. There is a solution how to measure negative temperature without some op-amp and negative voltage supply. Simply insert a diode between its ground pin and system ground which moves LM35's ground "up" to about 0.7V. Use the second analog input pin to measure this virtual ground and subtract the measured value from LM35's value.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

See LM35 datasheet, figure #7
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting idea to insert a diode.  I'll give it a try tonight.
I'm not quite sure how to measure the virtual ground though.
Where do I connect the second anolog pin to?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Connect it to another analog input. Ask Arduino to measure (always, this is important due to diode's temp coefficient 2mv / C) both inputs and perform a subtraction.

int tempValue = analogRead(LM35pin) - analogRead(LM35 virtual ground pin)

and convert it into celsius considering 5V Vcc = 1023 and 10mV / C of LM35
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the tips.  I've added the diode and fudged the math a bit, but it seems to be pretty accurate. smiley
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 2
Posts: 120
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could also use an LM34 which is the Fahrenheit equivilent of the LM35. Of corse that would mean buying an LM34 when you have the LM35 working fine now. Thought I would mention it just incase you ever need that addition analog pin for anything though.
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Won't I still need a diode and another analog input to get values under 32 degrees Fahrenheit?

Detailed Description
LM34DZ-Precision Fahrenheit temperature sensor. +32 degrees to +212 degrees F. Callibrated directly in degrees F. TO-92. Operates from 5-30V. TRNLM34DZ....  
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 2
Posts: 120
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, with the basic circuit you can get measure down to +5 deg F.
The description you have quoted is the maximum rating, i.e don't expose the LM34DZ to temperatures under +32 deg F as damage may occur to it, the LM34C..., has a temperature range from -40 to 230 deg F.
What sort of LM35 do you have as the LM35D is also rated at 0 - 100 deg C (+32 to 212 deg F)
I guess they will probably work at temperatures outside this range by National takes no responsiblity if they fail.
Logged

Pages: [1]   Go Up
Jump to: