Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Here is another odd thing that is happening. I also am using an analog temp sensor from AtlasScientific. It's a submersible sensor. When both sensor are wired up and running and when the AtlasScientific sensor touches water, the TMP36 sensor readings drop. I also noticed this when the AtlasScientific sensor touches something metallic.

The readings you get from the TMP36 alone do not look particularly inconsistent. They do, however, look as if they are steadily increasing each time to go into your read loop.

What happens if you extend the sampling period - either by increasing the delay between reads or by increasing the number of reads? Do the individual readings eventually level off, or do they continue to increase?

What's happening with your second sensor sounds like it has a short, which is pulling down the system's operating voltage and thus the reference voltage on the TMP36.

So you measurements are not necessarily "steadily increasing". They are probably more random. But since you have sorted them, they are printing out in ascending order. If you leave out the sort step, you should see a more random pattern to the readings.

OK, so the analog readings are printing after they are sorted. I feel better now.

Using the TMP36 alone, I'm going to say that your readings look fine.

When you're switching between the TMP36 and the Atlas Scientific, it looks to me like the ADC needs more time to stabilize. Sorted or not, you can see that it's moving towards the 210-220 range, where it ought to be. This is a common situation with multiplexed ADCs.

A simple thing to try is to do your read from the TMP36 (to switch the ADC) and throw those values away, then delay for about 100ms. After the delay, do your normal read routine.

Sorry for the delayed results on this topic. I actually tried what driverblock suggested without any luck; however, it is good advice! Here's what I eventually did to get the TMP36 to have consistent and accurate readings. Simply stated, it needs to be connected very close to the MCP3008 chip. I tried lots of things first before trying this. I ended up ordering a new temp sensor thinking the one I had was bad. I soldered it to a homemade cable about foot long. I found that the readings were even more inconsistent and off from true temp. This is what gave me the idea to solder it as close to the ADC chip as I can. Once I did that then my temp readings were accurate and consistent.

I don't know enough about electronics to understand why exactly. I do know that analog sensors are sensitive to signal degradation when connected via a long wire. I haven't heard any complaints about the TMP36 sensor being so sensitive to distance but then again most of the examples I find are from an Arduino setup and not from a Raspberry Pi with an ADC chip.

In any case, my temp sensor is working well now. I don't know if my conclusion is sound or not. I'm just happy it's working. :-) Oh and I am using driverblock's advice about throwing away the first read and waiting 100ms before getting a true read.

I'm also reading tmp36's connected to a mcp3008 with a similar python program but using the standard spi port pins. I've observed a little different phenomina with the tmp36's. When I noticed my calculated temperature reading was about 10% lower than expected, I decided to try different channels on the mcp3008. I soon discovered the same tmp36 sensor could report readings as much as 10% different from channel to channel but consistently the same on the same channel. Naturally I thought internal differences in the mcp3008 channels was to blame. Then I tried using a fixed resistor divider on each channel and obtained exactly the same readings on each channel. That's when I came across the Adafruit postings regarding odd tmp36 issues.

This morning I tried a Phidget 1124 temp sensor ($15.00) on each of the mcp3008's channels. Interestingly, this sensor reports the same reading on each channel. So, it seems my tmp36/mcp3008 issue is related to design characteristics of the tmp36 and how the mcp3008 accesses the tmp36. I suspect the mcp3008 acts somewhat like a multiplexor that cycles from channel to channel which must somehow confuse the tmp36. But still it is difficult to understand why each channel consistently reports a reading so much different from adjacent channels. I suppose once a tmp36 was permanently in place the formula could be customized for each mcp3008 channel.

Amazing - a .1uf capacitor between ground and the analog pin completely remedies my problem! With the capacitor directly across the sensor legs about 5" away from the mcp3008, each channel now reads exactly the same. Thanks for the tip :D