You are viewing an older revision! See the latest version

Xbee Pro

/media/uploads/tristanjph/08742-03-l.jpg

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 here. The whole list of devices that should work with this example can be found here.

Xbee_lib Hello World program

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     int device_serial[8];
00009     int security_key[8];
00010     int Pan_ID;
00011     char send_data[202];
00012     char read_data[202];
00013 
00014     xbee1.ConfigMode(); //Enter the xbee's config mode
00015     xbee1.GetSerial(device_serial); //Read the xbee devices serial into device_serial
00016     xbee1.SetKey(security_key); //Set the network key to security_key
00017     xbee1.SetPanId(Pan_ID); // set the PAN network id to Pan_ID
00018     xbee1.WriteSettings(); // Write the settings to non volatile memory
00019     xbee1.ExitConfigMode(); //Exit config mode
00020     xbee1.reset(); //Reset Xbee
00021 
00022     xbee1.SendData(send_data); //Send the data in send_data
00023     xbee1.RevieveData(read_data); //Put recieved data into read_data
00024 
00025 
00026 }

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.

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

Xbee_lib library

Import library

Public Member Functions

xbee (PinName tx, PinName rx, PinName reset)
Configure serial data pin.
int ConfigMode ()
Puts the Xbee into config mode.
int GetSerial (int *)
Gets the serial number/mac address of the Xbee and places it into serial_no.
int SetKey (int *)
Sets the encryption key to the one stored in security_key.
int SetPanId (int)
Sets the id of the PAN network for the Xbee to use.
int WriteSettings ()
Writes the settings to the Non volatile memory on the Xbee.
int ExitConfigMode ()
Exits config mode.
int SendData (char *)
Sends data in the send_Data buffer.
void RecieveData (char *, int)
Recieves data sent to the xbee.
void Reset ()
Resets the Xbee.

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


All wikipages