---

Monday, February 16, 2015

Accurate and Reliable Readings from a TMP36

I have been using the TMP36 for years, with Arduino, BeagleBone and now the Spark Core/Photon. It has often been reported in the Arduino forums that this chip is inaccurate and unreliable. Indeed a quick glance at the datasheet tells you accurate to 2 degrees C (which seems pretty poor).

I'm working on a Spark Core project for a book and tried out a TMP36. The results seemed totally mad, -25C when it should have been 17C. I checked the maths which was all fine. Then, thinking I had a duff TMP36, I connected my multimeter to measure the output of the TMP36. Suddenly the readings started to be accurate and stable! My magic multimeter was making things work right!

So, going back to the datasheet for the TMP36, the equivalent schematic looks like this:

To add a load resistor (I used 1k, but looking at the spec, the load should not really exceed 50uA so a 20k or 47k resistor would be better) to any microcontroller analog input, connect your resistor between Vout and GND on the TMP36.

So, if we have all been using the TMP36 incorrectly for years, then how has it ever worked?

Well, the Arduino has a relatively low input impedance to the analog inputs, so enough current flowed to ground to make it usable, if not terribly good. However the Spark Core has analog inputs that are biased to roughly 1.65V, which totally screws the TMP36 output, without any kind of load resistor. Even my high impedance multimeter voltage range was enough of a pull-down for it all to work.

So, the lesson is:

*** If your TMP36 is misbehaving, put a 47kΩ resistor between Vout and GND on your TMP36. ***

1 comment:

Kevin said...

Did you ever investigate this more? The TMP3x series data sheet doesn't mention anything explicitly about needing to load the output and I'm curious how you calculated the value needed here and if you checked the solution across a wide range of temperatures.

There are a fair number of discussions about the effect of source impedance effects vs samples rate on accuracy on the STM32 ADCs. There's a lot of information in "AN2834 - Application note - How to get the best ADC accuracy in STM32 microcontrollers" including a common recommendation in "4.2.7 External analog buffer usage" to use an op-amp as a buffer for high impedance sources. A capacitor across ADC to GND may suffice as a more primitive solution.