# Temp sensor

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.

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.

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.

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

Here is my 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";
}
``````

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.

See LM35 datasheet, figure #7

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?

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.

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

Thanks for the tips. I’ve added the diode and fudged the math a bit, but it seems to be pretty accurate. 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.

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…

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.