2
\$\begingroup\$

I get some curious data from my LM35DZ temperature sensor. Every minute or so I take 8 measurements 1/2-second apart and average them. The graph below shows that the accuracy of the measurements deteriorates noticeably towards the low end of the range (0°C). I connect the sensor's OUT pin to ATmega328's ADC pin directly - no resistors or capacitors - with 6 inches of unshielded hookup wire. The sensor is in the same plastic enclosure with XBee, humidity sensor, relay switching 110V-powered fan and a 12V to 5V voltage regulator.

Here's the graph illustrating the problem:

enter image description here

As you can see, at 20°C the accuracy is worse than ±2°C. I have a similar sensor connected to another ATmega328. With no other sensors or fans attached to it. And the accuracy is as expected (half a degree or so). So I'm positive it's my circuit (and not the sensor or the micro code).

Any ideas what could be affecting the accuracy and how I can improve it?

\$\endgroup\$
2
  • \$\begingroup\$ Have you measured the output of the device at 0C with an accurate voltmeter? It's possible that the issue is in the micro and the conversion, and not with the sensor. \$\endgroup\$ Jul 28, 2011 at 21:35
  • 2
    \$\begingroup\$ Please explain your graph and add and label x axis. LM35DZ gives an error typically of 0.2C at 0C compared to 50C. You don't say how large the error is (Y axis may be calibrated in kg of Yak's butter but it's not certain. If those are degrees K/1000 your accuracy may be as expected. Normal practice is to have 0 or low at left end of x axis. \$\endgroup\$
    – Russell McMahon
    Jul 28, 2011 at 22:14

2 Answers 2

3
\$\begingroup\$

Have you actually measured the voltage the LM35 is outputting with a multimeter? I would trust the LM35 far more than the ATmega's ADC to go completely down to 0 V.

From the graph you included, it looks like something is hitting a rail somewhere.

If it is indeed the LM35 outputting the errant voltages, try a pulldown (~50 kilohm?) on the output to ground (or better yet, -5 V).

You're measuring a very small voltage with the built-in ADC - 20 °C is only 200 mV. Furthermore, without a negative power rail, the sensor is only really good to 2 °C, and any bias current on the output (from the ADC) will probably affect the readings you get.

\$\endgroup\$
0
\$\begingroup\$

I assume you mean LM335Z and not LM35Z. Yes?

The following is based on the assumption that an LM335 is involved. If so, you appear to be using it incorrectly.

There are two ways to use an LM335. Either as an unadjusted 2 terminal device. Like this:

enter image description here

Output is 10 mV per degree K.

Or as an adjusted 3 terminal device like this:

enter image description here

Output can be greater or less than 10 mV/K depending on adjustment.

What appears to be happening is that a weak pullup or general leakage on your port pin is providing some bias for the sensor but not enough to drive it correctly across the range.

Look at the LM335 data sheet here for more information.

\$\endgroup\$
2
  • \$\begingroup\$ I actually meant LM35DZ, sorry about the typo. Here's the datasheet: national.com/ds/LM/LM35.pdf \$\endgroup\$
    – sudarkoff
    Jul 28, 2011 at 21:24
  • 5
    \$\begingroup\$ @sudarkoff and everybody - this kind of confusion is the reason why I keep insisting adding a link to the part's datasheet in questions. \$\endgroup\$
    – stevenvh
    Jul 29, 2011 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.