You are here

Using Xbee and Xbee Shields

Hardware

Install the Necessary Software


     1. Software Drivers for XBee explorer http://www.ftdichip.com/FTDrivers.htm
     2. You need a terminal program to communicate with the XBEE. We can use CoolTerm, or the Arduino serial monitor. Cool term settings can be copied from here http://examples.digi.com/get-started/basic-xbee-802-15-4-chat/3/
     3. Connect the XBEE you want to program to the xbee xplorer. Plug into USB port and open connection in CoolTerm.
     4. In the terminal window we are going to call the attention of the XBee by typing +++ DO NOT PRESS ENTER – but you should see “OK” appear once you do it. If you wait too long before you type another command, the XBee will stop responding to your requests. If this happens, just type +++ again.
     5. Now you are ready to configure the ID, MY, DL, etc., using AT commands. Look at the lecture slides for ID and MY, DL settings. The important part is that the xbees need to be able to transmit and receive by each other, on the same network ID.

Configure the Xbee

XBee Addressing

  • ATID is the network ID
  • ATMY is your source address (what you are listening to)
  • ATDL is your destination address (what you are broadcasting to).
    • FFFF is the special "broadcast to everyone" address (transmits to all xbees sharing your network ID, no matter what their addresses)
  • see page 20 of the datasheet for details.

Unicast

  • For two xbees to communicate with one another, they need to share the network ID (ATID).
  • For xbee 1 to transmit to xbee 2, xbee 1 DL (ATDL) needs to match xbee 2 MY (ATMY).
  • For xbee 2 to transmit to xbee 1, xbee 2 DL (ATDL) needs to match xbee 1 MY (ATMY).
  • A unicast has bidirectional communication between two arduinos.

Testing the Xbee

Xbee basic communication example

Remote xbee transmits to local xbee.
  • 2 xbees, 1 arduino, 1 usb adapter
  • xbee A on usb adapter. open serial port to view output.
  • xbee B on arduino. Upload sketch:
  • delayedASCIITable.zip
  • The xbee on the arduino sends the ASCII table to the xbee on the laptop USB.

Xbee Serial Echo example

  • XBee Serial Echo example:
  • same hardware setup as above
  • XbeeSerialEcho.zip
  • in serial monitor, whatever you type into the local xbee (usb port) should be echoed back by the remote xbee (on arduino).
 XBee Send / Receive Button Example
  • Arduino 1 reads a digital input and transmits to Arduino 2, which displays it on its LED.
  • Hardware setup:
    • two arduinos with xbees in same network (matching ATID), configured to transmit to each other (ATDL from transmitter matches ATMY from receiver)
    • Arduino 1, sender, has a digital input connected to pin 2.
    • Arduino 2, receiver, has an led attached to pin 13 (true by default).
 More Elaborate Networking

 

Miscellaneous

XBee cable replacement code (2 way serial communication btwn arduino and computer):

https://raw.github.com/sparkfun/xbeeconfigure/master/examples/XBeeCableReplacement/XBeeCableReplacement.pde

Zigbee Explorer for the Computer:

http://www.sparkfun.com/products/8687

Resetting the Zigbee to default settings:

http://www.sparkfun.com/tutorials/192#defaults 

Mechatronics lecture on ZigBeee: