So I have some future plans on setting up a homebrewing control+measurement system, but I'm very new at wiring up my own electronics so I'm starting small here to learn how things work. With this in mind, I recently acquired an MCP3008 and TMP36 to play around with reading an analog temperature sensor through a Raspberry Pi.
I started with the python code from http://learn.adafruit.com/send-raspberr ... m/overview to make things work initially. This gave me a temperature reading that matched both the house thermostat and a thermocouple reading through my multimeter. Great!
Now the confusing part...I liked the idea of using hardware SPI instead of bitbanging, and found http://jeremyblythe.blogspot.com/2012/0 ... nputs.html to be instructive. I installed the necessary python bits, replaced the bitbanging readadc function with the hardware spi one, and ran it. It seemed to be working great, except now the temperature didn't match room temperature at all. The voltage reading was about 20-25mV lower, and the resulting temperature was about 2-3C too low. I switched back and forth between hardware SPI and bitbanged SPI a couple times just to check, and sure enough I consistently see a higher temperature (that matches room temperature much more closely) when using the bitbanged SPI.
Just to make sure, I checked the voltage on the middle pin using my multimeter, and lo and behold it matches the voltage I get using hardware SPI on the money. I removed the sensor from my breadboard, hooked it to both 3.3v and 5v with my multimeter directly connected and confirmed that I got the same answer each time, and that this was consistent with the measurement from the hardware SPI driver. I'm now fairly certain that the close match to room temperature using the bitbanged SPI was serindipity. Does anyone have some insight as to what is going on here?