I have rigged up a basic circuit as follows:
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’][‘adc-0’])
This is displaying the value of 30 on screen. Am I missing something obvious?
I am satisfied with you and you are in right .
You need to wire-up VREF (Pin 14) before you’ll get any useful values from the A/D. I usually tie it to VCC.
Of course, you’ll also need to parse the packet for a value for “adc-0” , then convert it to an actual voltage using V=(VREF)(adc-0)/1023, and finally a temperature using T= (100)(V) - 50.
Thanks for your reply. I understand the series 2 XBees have an internal VREF, so that shouldn’t be necessary.
I think i’ve tracked the issue down to the power supply. When running the circuit from batteries, the reading is much more accurate. I think the USB explorer must be introducing some noise along the way. I’m now looking at wiring up a circuit with a voltage regulator to see if that’s more reliable.
Interesting, I’m currently using a 3V Lithium Battery Powered XBee S2C TH with the MCP9700A Temperature Sensor. I have also found that the XBee ADC’s are giving me strange inaccurate results.
I’ve contacted the Digi Tech Support and they inform me the ADC’s have a ±20mV Error which translates to ±2 DegC which is totally unacceptable.
I’m hoping the Digi Engineers will add a ADC calibration routine to eradicate the ±20mV error into a Firmware upgrade some time soon.
I’ve created my own ADC calibration routine using linear equation y=mx+c which works well but I’d prefer Digi to solve it in a more elegant way.
The ±2mV is not related to the firmware but to the hardware and its tolerance. As a result, there is not much Digi can do with firmware.
±20mV is the ADC Error which could be calibrated out using the FIRMWARE!
Hi man I have a question for you, I am a new xbee user, I got 2 xbee s2c, and I want to know if I can transmit from one of the xbee modules the data get from a temp sensor to the other xbee without any microcontroller (Arduino, raspberry pi, etc). I mean like set a periodically transmission of analog values
Sure you can. You just need to make sure you get the right sensor. Some output an Analog voltage that is 0 - 1.2V, others 5V and still others UART data.
Yes I’m using the MCP9808 I2C temperature sensor instead of relying on the ADC accuracy. I’ve heard that the Xbee ADC issues have now been solved by DiGi but I haven’t had time to revisit this project as I endid up using the ESP8266.
I had the same problem with LM35. I was using a 5V/120 mA power supply and then the analog input values were totally crazy. So I needed to replace the 120mA supply for a bigger one, in my case I had another one of 3A.
As to the calculation I made a circuit adjustment as you see bellow and the formula (AD05100)/1024.
| LM35 |
15kΩ ----> AD0
ps. don’t forget to connect Vref to Vcc (3.3v)