Go Down

Topic: Temp sensor (Read 2 times) previous topic - next topic

Pauly

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.

TBAr

#1
Jan 05, 2010, 05:27 am Last Edit: Jan 05, 2010, 05:28 am by TBAr Reason: 1
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.

Webmeister

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.

MikMo

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

Pauly

Here is my code
Code: [Select]
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";
}

Pepe34

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.

Pepe34

See LM35 datasheet, figure #7

Pauly

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?

Pepe34

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

Pauly

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

mattd2

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.

Pauly

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

mattd2

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.

Go Up