Xbee Pro

The Xbee Pro is a wireless unit based on the zigbee stack. There are several different models that can be purchased. This example was tested using a series 1 Xbee pro found [[https://www.sparkfun.com/products/8742|here]].

Hello World

Import programXbee_Hello_world_A

Hello world program showing use of xbee-lib. Sends data read from serial terminal, then waits for a response.

Library

Import libraryxbee_lib

A library allowing basic functions of the XBEE pro to be used. Currently supported are: Enter/exit config mode, reading device serial number, setting encryption key, writing settings to non volatile memory and sending data strings.

Datasheet

http://www.digi.com/support/productdetail?pid=3257&type=documentation

Notes

Xbee_lib Hello World program

Connect A to your computer and fire up your favourite serial terminal

Import program

00001 #include "mbed.h"
00002 #include "xbee.h"
00003 
00004 xbee xbee1(p9,p10,p11); //Initalise xbee_lib
00005 Serial pc(USBTX, USBRX); //Initalise PC serial comms
00006 
00007 int main()
00008 {
00009     char send_data[202]; //Xbee buffer size is 202 bytes
00010     char read_data[202]; //Xbee buffer size is 202 bytes
00011 
00012     while(1) {
00013         pc.scanf("%s",send_data); //Read data from serial console
00014         xbee1.SendData(send_data); //Send data to XBee
00015         xbee1.RecieveData(read_data,0); //Read data from the XBee
00016         pc.printf("You said:%s",read_data);
00017     }
00018 }

Download this to B and send it some data!

Import program

00001 #include "mbed.h"
00002 #include "xbee.h"
00003 
00004 xbee xbee1(p9,p10,p11); //Initalise xbee_lib
00005 
00006 int main()
00007 {
00008     char read_data[202]; //Xbee buffer size is 202 bytes
00009 
00010     while(1) {
00011         xbee1.RecieveData(read_data,0); //Read data from the XBee
00012         xbee1.SendData(read_data); //Send data to XBee
00013     }
00014 }

Wiring up the Xbee Pro

For the example to work you only need to connect up 5 pins, VDD, GND, TX, RX and Reset. The Xbee pro has 2mm pitch sockets, so you might want to get a breakout board that increases the spacing to the standard 0.1". These can be ordered from sparkfun here. If you don't want to solder it directly to the Sparkfun breakout board, you will also need two .2mm SIP sockets (they do not come with the breakout board!). Adafruit also has a Xbee breakout board with a few more features.

Warning

Do not connect this device to 5V power, it uses 3.3V power!

The xbee will operate on any voltage from 2.8-3.4V. Because of the radio transmission a good stable power supply is vital to get good, reliable transmissions. VDD should be connected to xbee pin 1 and GND to xbee pin 10. The reset line should be connected to pin 5. The reset can be connected to any digital out mbed pin, in this example were using mbed pin 11.

The data in (RX) and data out (TX) lines need connecting to one of the serial ports on the mbed. Because this example was tested on the LPC11U24, were going to connect TX to mbed pin 9 and RX to mbed p10. The TX is then going to connect to xbee pin 3 and the RX to xbee pin 4.

/media/uploads/tristanjph/xbee_wiring.png

Using the Xbee-Pro

The commands that xbee_lib currently supports are:

  • Entering/Exiting config mode
  • Getting the device serial number
  • Setting the network security key
  • Setting the PAN ID of the network
  • Writing the settings to non volatile memory
  • Sending Data
  • Receiving Data
  • Resetting the Xbee

Things to be careful of:

  • The Xbee will take 2 seconds to enter into config mode
  • Resetting the Xbee will take 1 second
  • Settings will only be saved if written to non volatile memory
  • All the devices that you want to communicate with need to have the same PAN ID and security key

More Examples

Useful Links

Data Sheet: http://ftp1.digi.com/support/documentation/90000982_G.pdf

If your Xbee stops working, use a serial loop through program on an LPC1768 and run this program to restore defaults: http://ftp1.digi.com/support/utilities/40003002_B.exe

There is a new mbed library for Xbee from Digi at https://developer.mbed.org/teams/Digi-International-Inc/