Xbee communication

Update 14 Jul, 2014: adapted to new software version, added code for arduino, renew missing photos.
Note on 27 Feb, 2014: some images have gone missing. I try to track where there are and bring this tutorial back to life.

Since I managed to get xbees work, I decided to write a tutorial – also for me to remember how I did it 🙂

The best program I found to communicate with xbees on os x is CoolTerm. Make sure you have the newest version, the older ones were a bit buggy (couldn’t connect to all xbees or couldn’t reconnect).  There is a Processing app funnel and XBEE config tool also available, but the version I tried out did not work. Another option is the  Moltosenso Network Manager IRON, but I haven’t tried it out yet.

The basic steps are:

1) configure your xbee pair (or one sender and receivers)

2) hook up other xbee with arduino, the other with a computer

3) send some data!

It is fairly simple, but there are a few glitches here and there.

This site provided me the best tutorial in using and configuring the XBee.

xbee config steps (might be suitable only in our lab):

1) mount first Xbee (series 1) to the Sparkfun XBee (regulated?) Explorer. You could probably also use the XBee shield or some other methods

xbee explorer

2) Open up CoolTerm. Select options, choose the correct serial port ( should be something like usbserial-A600xxxx)

 

If you want to see what you typing, you need enable “Local Echo”.

Ok, and press Connect. You should be talking to your xbee.

3) test out: press +++ (do not press enter), the XBee should answer OK. This puts the XBee into configuration mode. We need to configure 3 things: PAN ID (common to all XBees in the same network), My ID (the ID of this XBee) and the Destination ID. In the end it is handy to write this to the XBee so it wont be erased from memory. These are done by typing messages which begin with letters AT followed by two letters and a value, and by pressing enter:

ATID2171<enter> (setting up the pan id, can be anything from 0000 to ffff)

ATMY1<enter> (setting up this device id)

ATDL0<enter> (setting up to which device to communicate to)

ATWR<enter> (write these to the XBee)

Press enter after each line. The XBee should talk back. Finished! Press Disconnect.

 

4) Swap the XBee, Connect (the port should be the same, it is an address for the XBee Explorer) The second XBee has the same PAN id, but different ID and listens to different XBee:

ATID2171<enter>

ATMY0<enter>

ATDL1<enter>

ATWR<enter>

As far as I understood, there could be many XBees, to which the one device is talking to. So setting ATMY value to a different one, but listening to 0 or 1 allows the XBee network to be extended.

Attach one of the paired Xbees to an Arduino XBee shield in the lab, and make sure the jumpers are set to XBEE, not USB. Build a sample circuit, e.g. a potentiometer to Arduino analog input 0, +5V, Ground and upload the code to Arduino. If you still have the second XBee connected to the computer, you can display the values on CoolTerm (or use terminal – screen /dev/tty.usbserial-A600whateverwasit if you know how to run screen on Unix terminal) neat!

Code for Arduino:

int Data=0;

int ledpin=13;

void setup() {

Serial.begin(9600);

pinMode(ledpin,OUTPUT);
}
void loop() {

if(Serial.available()>0){

Data=Serial.read();

if(Data==’1′){

digitalWrite(ledpin, HIGH);

Serial.print(Data);    }

if(myData==’2′){

digitalWrite(ledpin, LOW);

Serial.print(Data);    }

else{    Serial.print(Data);

}

}

}

some things to watch out for:

– FTDI Drivers – are they installed? If you can’t see your XBee Explorer port in CoolTerm, this might be the cause
– XBee configuration: did it work out? Got OK’s? Unique ID’s and common PAN ID?
– check out the jumpers on the XBee shield. More info on our shield.
– range of the XBee: claimed to be about 100 meters, but…
– The XBee returns to normal state from configuration state if nothing happens for a while. So press +++ again to return to config state.
– You can check out the current value of a setting by just issuing the command without arguments (ATID<enter> or ATMY<enter> for example).

Worth testing out:
– XBee pin configuration: analog pin and the voltage pin in the XBee shield are…
– building a network of many XBees
– creating a portable, computer-free XBee-arduino system (LCD / LED system, different sensors etc)

Much more communication can be done, check out the XBee tips & tricks page at ladyada.