Python – XBee + TMP36 temperature sensor – returning inaccurate values

pythontemperaturexbeezigbee

I have rigged up a basic circuit as follows:

Circuit diagram

The XBee is a Pro, series 2. It is configured as a Router using the AT firmware. Pin 20 (D0) is configured as an analog input. There is a co-ordinator XBee running the Co-ordinator API firmware.

When I measure the TMP36 using a multimeter, I can see a voltage of 0.752. However, the XBee is returning values of around 30 at the same time. I have a basic Python script (using the XBee Python API) running that grabs the data and outputs it as follows:

packet = xbee.wait_read_frame()
print 'Temp: ' + str(packet['samples'][0]['adc-0'])

This is displaying the value of 30 on screen. Am I missing something obvious?

Best Answer

I think I've worked it out. The power was coming through a SparkFun USB Xbee Explorer. This was rigged up into a breadboard, and power was provided by USB from a PC.

I've replaced this with a basic adaptor, a 3.3V voltage regulator and a 5v power supply. This seems to have given a much more reliable signal. I'll do some more digging to see if there is some noise coming into the circuit somehow.