# temperature sensor distance LM34 vs 10k

I need to put a temperature sensor outside. this will be about 10 meters from my Arduino.

the parts I have on-hand are a 10k NTC and an LM34

I would like to read outside temperature of 1°F or better.

the LM34 gives me 0.49 degree steps

float temp = (5.0 * analogRead(analogInPin) * 100.0) / 1024;

the 10k NTC just came today.

looking for advise before I add the wire and extend the cable.

dave-in-nj:
I need to put a temperature sensor outside.
this will be about 10 meters from my Arduino.

the parts I have on-hand are a 10k NTC and an LM34

I would like to read outside temperature of 1°F or better.

the LM34 gives me 0.49 degree steps

float temp = (5.0 * analogRead(analogInPin) * 100.0) / 1024;

the 10k NTC just came today.

looking for advise before I add the wire and extend the cable.

To go right down to 1F, the thermistor might be the better choice.
An LM34 is only accurate down to 5F, and loses accuracy below that temperature.
(3F under ‘no load’ conditions.)
A thermistor might be better with regard to noise, too. (I’m not sure of this point though.)

Linearity of a thermistor is bad without jumping through hoops.
And you will only use a fraction of the A/D, so resolution is also bad.
Best way (stability and higher resolution) for the LM34 is to make your own Aref, derived from the 3.3volt supply.
Connect a 10k resistor between the 3.3volt pin and the Aref pin, and enable EXTERNAL Aref in the code.
https://www.arduino.cc/en/Reference/AnalogReference
Measure the voltage on the Aref pin (~2.5volt), and use that voltage in the code (instead of 5.0).
Use decoupling caps on the LM34 as per datasheet.
A resistor in series with the LM34 output, and a 100n cap on the Arduino side to ground might also be needed.
Leo…

Wawa: Linearity of a thermistor is bad without jumping through hoops. And you will only use a fraction of the A/D, so resolution is also bad. Best way (stability and higher resolution) for the LM34 is to make your own Aref, derived from the 3.3volt supply with a resistor. Connect a 10k resistor between the 3.3volt pin and the Aref pin, and enable exernal Aref in your code. https://www.arduino.cc/en/Reference/AnalogReference Measure the voltage on the Aref pin (~2.5volt), and use that voltage in the code (instead of 5.0). Use decoupling caps on the LM34 as per datasheet. A resistor in series with the LM34 output, and a 100n cap on the Arduino side might also be needed (noise). Leo..

As long as a bit of inaccuracy below 5F is acceptable, that sounds like the way to go then. I didn't know about the non-linearity of a thermistor. I actually thought they were pretty good. Another lesson learned. (I knew there was a reason why I hang around these forums. :) )

I think the non-linearity comes in when you make a voltage divider with a fixed resistor.
Not if you feed the thermistor with a current source.
Should look at a few datasheets though.

Don’t know where Dave lives.
-15C is pretty cold.
Leo…

Wawa: I think the non-linearity comes in when you make a voltage divider with a fixed resistor. Not if you feed the thermistor with a current source. Should look at a few datasheets though.

Don't know where Dave lives. -15C is pretty cold. Leo..

New Jersey is my guess. It's 6C there right now. Too @#\$% cold for me. :D

liudr: LM34 is a bad choice. Low temp gives low voltage. Then long wire will further reduce the voltage. Thermister is better. The way to find the right fixed resistor is to estimate the range of temperature the thermistor will sense. Then take the geometrical average of the thermistor resistance at the max and min temperature. This average gives you a good choice for fixed resistor. A thermistor has best accuracy when sensed with an ADC and a fixed resistor that is equal to the thermistor's resistance. Constant current supply is the best of course.

This is what I originally thought. And the LM34 datasheet does say that accuracy suffers at or below 5°F. (I feel like a yo-yo. :) )

liudr: LM34 is a bad choice. Low temp gives low voltage.

Then long wire will further reduce the voltage.

Thermister is better.

The way to find the right fixed resistor is to estimate the range of temperature the thermistor will sense. Then take the geometrical average of the thermistor resistance at the max and min temperature. This average gives you a good choice for fixed resistor. A thermistor has best accuracy when sensed with an ADC and a fixed resistor that is equal to the thermistor's resistance. Constant current supply is the best of course.

No problem. The Arduino measures from 0volt.

Not true. Arduino's input resistance is extremely high. Wire resistance is an almost infinite fraction of that. Wire capacitance is also not a problem with a resistor on the LM34's output.

Prove it. I like to see numbers (over the user's outdoors temp range). The LM34 has a theoretical constant resolution of ~0.25F over the whole temp range with the method I gave.

Sure.

OldSteve: This is what I originally thought. And the LM34 datasheet does say that accuracy suffers at or below 5°F.

Sure, but does Dave use the temp range below 5F. That's mighty cold. Leo..

Wawa: Sure, but does Dave use the temp range below 5F. That's mighty cold. Leo..

We'll have to wait for him to answer that. I would think that low-temperature range isn't important, but it might be.

The other thing in favour of a thermistor is that induced noise on the lines should be lower than with an LM34. The LM34 has a very high output resistance/low drive current.

OldSteve: The other thing in favour of a thermistor is that induced noise on the lines should be lower than with an LM34. The LM34 has a very high output resistance/low drive current.

RF noise can/should be cancelled with an RC filter. The LM34 needs a series resistor anyway with a long wire. Easy to add a 100n cap from A-in to ground to that. That would also be needed with a thermistor.

Other noise can be cancelled in software. Wise to add smoothing to the code anyway. LM34 or thermistor.

Drive current is not important because of Arduino's high input impedance. Leo..

Wawa: RF noise can/should be cancelled with an RC filter. The LM34 needs a series resistor anyway with a long wire. Easy to add a 100n cap from A-in to ground to that. That would also be needed with a thermistor.

Other noise can be cancelled in software. Wise to add smoothing to the code anyway. LM34 or thermistor.

Drive current is not important because of Arduino's high input impedance. Leo..

I agree, but just thought I'd mention that the LM34 would be more susceptible to noise. Hardware and/or software filtering can fix that, though, as you say.

Personally, I'd more then likely just go with whatever was closest to my hand. :D Either method is probably equally acceptable for Dave's purpose.

I did some calculations with a random thermistor resistor table I found online. That worked out to ~84% of the A/D range (resolution/values) of an LM34 over a 250F range. Not as bad as I thought. But AFAIK, thermistors need crooked maths for a lineair scale. That could make them hard to use over a large temp range. My preferred choice between the two would be the LM34. Leo..

You're pretty much right. Wiki says that NTC thermistors are non-linear over a wide measurement range, but linear with small ranges of temperature. It doesn't say just how small a range. I would think that it's not too bad over an outdoor ambient temperature range, but not perfect.

Wikipedia: Over large changes in temperature, calibration is necessary. Over small changes in temperature, if the right semiconductor is used, the resistance of the material is linearly proportional to the temperature. There are many different semiconducting thermistors with a range from about 0.01 kelvin to 2,000 kelvins (−273.14 °C to 1,700 °C)

Thermistor

from NJ.com New Jersy's website this was from last winter :

New Jersey is one of the most anomalously cold places on the planet this morning, and that seems fitting - it appears all but certain that February 2015 will be one of the coldest months on record.

And, unfortunately, there's no sign of the cold letting up anytime soon.

Led by Walpack at -20 degrees, temperatures fell below zero in many parts of the state this morning for the third time in less than a week as the latest round of Arctic air plunged into the region.

Much of the state fell below zero last week as well, with Walpack falling to -17, the coldest mark in New Jersey yet this year. All told, high temperatures in New Brunswick have remained below freezing 21 times thus far this winter, and lows have fallen below 10 degrees 15 times

dave-in-nj: from NJ.com New Jersy's website this was from last winter :

New Jersey is one of the most anomalously cold places on the planet this morning, and that seems fitting - it appears all but certain that February 2015 will be one of the coldest months on record.

And, unfortunately, there's no sign of the cold letting up anytime soon.

Led by Walpack at -20 degrees, temperatures fell below zero in many parts of the state this morning for the third time in less than a week as the latest round of Arctic air plunged into the region.

Much of the state fell below zero last week as well, with Walpack falling to -17, the coldest mark in New Jersey yet this year. All told, high temperatures in New Brunswick have remained below freezing 21 times thus far this winter, and lows have fallen below 10 degrees 15 times

Meantime, we're cooking here, with temperatures often in excess of 40C, (104F), in February. And it was over 40C here yesterday, for that matter. Gonna be a hot Summer.

http://playground.arduino.cc/ComponentLib/Thermistor2

/*(Ground) ---- (10k-Resistor) -------|------- (Thermistor) ---- (+5v)
|
Analog Pin 0

http://playground.arduino.cc/ComponentLib/Thermistor2
*/

%box%[@
#include <math.h>

double Thermistor(int RawADC) {
double Temp;
//         =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;            // Convert Kelvin to Celcius
Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}

void setup() {
Serial.begin(115200);
}

void loop() {
Serial.println(int(Thermistor(analogRead(0))));  // display Fahrenheit
delay(100);
}

this does not compile.
http://playground.arduino.cc/ComponentLib/Thermistor2
the simple version.

I am hoping for a simple version, accuracy can suffer at this stage.

OldSteve:
Meantime, we’re cooking here, with temperatures often in excess of 40C, (104F), in February. And it was over 40C here yesterday, for that matter. Gonna be a hot Summer.

I had an idea that if you can dig a hole deep enough, then another next to it,
connect ahuge fan. it would take 3 months for the air to get to the bottom and 3 more to get back up.
that way, you dump cold winter air in, and 6 months later that cooling air will be welcome in the heat of summer.
Murphy’s law, correlation #7 : every man has a plan that will not work.

dave-in-nj: I had an idea that if you can dig a hole deep enough, then another next to it, connect ahuge fan. it would take 3 months for the air to get to the bottom and 3 more to get back up. that way, you dump cold winter air in, and 6 months later that cooling air will be welcome in the heat of summer. Murphy's law, correlation #7 : every man has a plan that will not work.

Ha ha. Dig one right through and I'll give you some of my heat.

And that code, (the simple version), compiles fine for me. I just had to remove "%box%[@" from the top.

no joy on that one,

#include <math.h>         //loads the more advanced math functions

void setup() {
Serial.begin(9600);
}

double Thermister(int RawADC) {  //Function for Steinhart-Hart equation
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;              // Convert Kelvin to Celsius
Temp = (Temp * 9.0)/ 5.0 + 32.0;
return Temp;
}

void loop() {
int val;
double temp;
temp=Thermister(val);
Serial.print("temp F = ");
Serial.println(temp);
delay(1000);
}

small changes, this works.

Wawa: No problem. The Arduino measures from 0volt.

Not true. Arduino's input resistance is extremely high. Wire resistance is an almost infinite fraction of that. Wire capacitance is also not a problem with a resistor on the LM34's output.

Prove it. I like to see numbers (over the user's outdoors temp range). The LM34 has a theoretical constant resolution of ~0.25F over the whole temp range with the method I gave.

Sure. Sure, but does Dave use the temp range below 5F. That's mighty cold. Leo..

LM34 have different ranges http://www.ti.com/lit/ds/symlink/lm34.pdf −50°F ≤ TJ ≤ 300°F for the LM34 and LM34A; hermetic TO-46 −40°F ≤ TJ ≤ 230°F for the LM34C and LM34CA; and +32°F ≤ TJ ≤ 212°F for the LM34D LM34C, LM34CA, and LM34D are available in the plastic TO-92 anyone know where I can get metal cup/can to protect this device ? the 10k was potted in such a cup/can/sleeve