using an xbee to read an analog signal remotely from an ardu

What I’m trying to do is fairly simple - I want an arduino to be able to read the value of a resistor remotely (continuously and in real time). It seems that using an xbee (series 1) is the easiest way to do that, but I’m open to suggestions.

It looks like I should create a voltage divider from V+ to ground between a “dummy” resistor and the one I want to read, and then send Vout to an “analog in” pin (i.e. AD0) on the xbee (or use the integrated pull-up resistor for the voltage divider?). I’ll set that pin as an Analog to Digital Converter, then send that signal to another xbee, which will be read by the arduino. This arduino will run on it’s own, not hooked up to a computer.

I’ve been looking through the documentation but still have a few questions:

First, the xbee datasheet says “Minimum connections: VCC, GND, DOUT & DIN” on page 7. From the remote xbee all I want to send is an analog signal, which I have to attach to AD0, and it shouldn’t be receiving any data (which it needs to send anywhere, at least). What do I do with DOUT and DIN? why do they need to be connected to anything? How do I make it just send the data that’s coming from AD0? It looks like xbee’s were meant to interface with microprocessors - but I don’t want the expense/bulk/complexity if possible.

Writing to the xbee appears to be pretty simple - I just use an xbee explorer board (http://www.sparkfun.com/commerce/produc … ts_id=8687) to connect to my computer, install the drivers and run XCTU, make sure the BAUD rates are right and then connect to the xbee.

for the remote xbee:

+++ #Enter AT Command Mode

ATDL=1234 #set the 16-bit destination address (address of the other device)

ATMY=5678 #set the 16-bit local address (address of this device)

ATD0=2 #Set AD0 to the Analog/Digital Converter mode

ATIR=32 #Set read rate as 50ms (32 in hexadecimal = 50 in base 10).

ATIT=1 #Sets the buffer to hold only one data sample before sending

ATPR 4 #Enable pull-up resistor on AD0/Pin 20 (if this will work?)

ATWR #Write changes to non-volatile memory

ATCN #Exit command mode

for the Base xbee:

+++ #Enter AT Command Mode

ATDL=5678 #set the 16-bit destination address (address of the other device)

ATMY=1234 #set the 16-bit local address (address of this device)

ATP0=2 #sets pin 6 to output a PWM signal. (not sure if this is necessary)

ATIU=1 #sets I/O data received to be sent out UART as serial data

ATIA=5678 #binds the outputs to the module with MY=5678

ATWR #Write changes to non-volatile memory

ATCN #Exit command mode

On the arduino, it looks like I can get a header board that plugs the xbee into the arduino, or just use wire to connect DO to TX and DI to RX. Then within the arduino code I have while loop checking if serial data is available (Serial.available>0), and if it is, read it (IncomingByte=Serial.read() ), then process it and extract the info I want from the data stream. Alternatively, I could attach xbee pin 6 to an arduino PWM pin and read this signal, ignoring the serial data - if I don’t do this I think I don’t need the ATP0=2 command above, right?

Sources:

http://www.sparkfun.com/datasheets/Wire … asheet.pdf

http://www.instructables.com/id/Changin … tes/#step1

http://code.google.com/p/xbee-api/wiki/XBeePins

http://www.arduino.cc/en/Serial/Available

The minimum signals list assumes serial communication. You don’t need the Din, Dout signals if you are using the analog inputs. I do use several XBees in this manner.

Do read about the full scale input voltage for the ADC for picking the resistors values and doing the scaling from the ADC value to what you need.

I didn’t go over the XBee set-up details. Try what you have and post back here if you are unsure of any.

waltr:
The minimum signals list assumes serial communication. You don’t need the Din, Dout signals if you are using the analog inputs. I do use several XBees in this manner.

Do read about the full scale input voltage for the ADC for picking the resistors values and doing the scaling from the ADC value to what you need.

I didn’t go over the XBee set-up details. Try what you have and post back here if you are unsure of any.

Thanks for the input. I looked through the xbee documentation and can't find any info on what vrefl is, but vrefh might be as low as 2.8v. I'll be using a 3.3v power source. The resistor I'm trying to read can be as high as 1M ohm, and as low as 200 ohms. I take it I can't just use a normal voltage divider then.

I suppose I could put a 1k ohm resistor in parallel with the one i’m measuring, and then the effective resistance will range from 160 - 1000 ohms. If i then put that in a voltage divider with a 500 ohm resistor, that gives me a Vout range of .82 - 2.2V, which should be good assuming vrefl is less than .82. Anyone have a better suggestion, or know what vrefl for an xbee is?

The XBee Vref depends on which XBee you have. The Series 2 XBee hardware has a built in Vref set to 1.2V.

The Series 1 XBee hardware requires an extenal Vref applied to pin 14. This is the Vrefh symbol in Table 1-04 and can be in the range of 2.08V to Vcc (3.3V). The analog input voltage (ADC pin in) is then scaled to this Vref.

Your ideas on scaling your voltage divider may work. But rather than using the Vcc (3.3V) for your resistors use the Vref. At least then you will never exceed the ADC range.

waltr:
The XBee Vref depends on which XBee you have. The Series 2 XBee hardware has a built in Vref set to 1.2V.

The Series 1 XBee hardware requires an extenal Vref applied to pin 14. This is the Vrefh symbol in Table 1-04 and can be in the range of 2.08V to Vcc (3.3V). The analog input voltage (ADC pin in) is then scaled to this Vref.

Your ideas on scaling your voltage divider may work. But rather than using the Vcc (3.3V) for your resistors use the Vref. At least then you will never exceed the ADC range.

hmm. so then, since I'm using series 1 (sparkfun has an unlabeled xbee and a "series 2.5" so I take it the unlabeled one is series 1), I can just run a jumper from Vcc to pin 14, and then do as I posted above.

Yep.

slade:

waltr:
(sparkfun has an unlabeled xbee and a “series 2.5” so I take it the unlabeled one is series 1)…

Because the XBee’s are popular, Sparkfun needs to take a moment and properly label and describe series 1 versus series 2.

This has been previously suggested.

I doubt they’ll notice such in these postings.

I fully agree Steve.

Its the first question I ask when someone has an XBee problem.

This is the page that explained to me how to set up the ADC stuff:

http://www.faludi.com/2006/12/03/xbee-d … -with-adc/

I agree that the Series 1/2.5 thing is unnecessarily confusing.

Also yes, I’ve simply run a jumper from Vcc to the Vref pin, and it works fine.