XBee Library

The XBee library, written by Andrew Rapp, is for communicating with XBee wireless modules in API mode.

Download: Included with the Teensyduino Installer
Latest Developments on Github

Hardware Requirements

The simplest way to use XBee with Teensy is this adaptor board.

XBee
Pin
FunctionTeensy 2.0
Pin
Teensy++ 2.0
Pin
13.3V Power(use 3.3V regulator)
2Data: XBee -> Teensy72
3Data: Teensy -> XBee83
10Ground11

Configured for TeensyConfigured for Teensy++

Configuring XBee with X-CTU Software

XBee modules need to be configured with the X-CTU software.

Before running X-CTU, upload the USBtoSerial example, found in File > Examples > Teensy > USB_Serial > USBtoSerial.

Tools > USB Type must be set to Serial before upload to Teensy.

When you run X-CTU, select the "USB Serial" port which is Teensy (running the USBtoSerial sketch), and then click "Test / Query". If "Test / Query" fails, check your connections and power to XBee.

To access XBee's settings, click the "Modem Configuration" tab, and then click "Read".

From here, you can configure your XBee for API mode.

Using the XBee Library Examples

The XBee examples use the NewSoftSerial library because the Arduino Serial port is need to talk to XBee. On Arduino, you would need to connect another USB-Serial converter to the NewSoftSerial pins.

On Teensy there is no need for NewSoftSerial and an extra USB-Serial converter. You can use the USB port, because XBee uses the completely separate Uart pins. To make the examples work easily, remove the NewSoftSerial object, and add a #define to use Serial in place of "nss".

//NewSoftSerial nss(ssRX, ssTX);  // not needed for Teensy
#define nss Serial                // "nss" prints to Arduino Serial Monitor

With Teensy, XBee is normally used with Serial1 on Teensy 2.0 and Teensy++ 2.0, or Serial3 on Teensy 3.0. The setSerial() function should use Serial1, Serial2 or Serial3.

  // start serial
  Serial1.begin(9600);     // change to Serial1 for Teensy
  xbee.setSerial(Serial1);

 

 

 

TODO: help wanted... to write the rest of this page with actual usage examples. Here is the main XBee library page.

 

TODO: test this adaptor with the new wifi modules (update: Oct 20, 2011: a pair of WiFi modules are on order... plan to test soon and add photos + results here)