Getting Started

I've had quite a few people getting in contact asking for support with the initial setup and configuration of libxbee. As a result, I felt that it would be worthwhile writing this guide. libxbee is very straight forward, once you understand the principals involved.


  1. Is there anything I should know before I dive in?
  2. How do I get the source code?
  3. Can I download compiled binaries?
  4. How do I get it running on my OS?
  5. Which modules should I use?
  6. How should my modules be configured?
  7. Creating connections
  8. Using connections
  9. Advanced connections
  10. Running some samples

Other Resources

How Should My Modules be Configured?

The other end of the XBee link does not have to match API mode or baud rate. The XBee connected directly to libxbee must be configured as below, but other modules in the network may be configured 'transparent' access or a different baud rate.

There are two configuration options that must be correctly configured for libxbee to communicate with XBee modules. Aside from the API mode and the serial interface, the XBee module can be configured differently.

API Mode

I have experienced issues with XBee modules not operating correctly in API mode 2, so I would advise against its use. Having said this, it is possible to run libxbee in API mode 2 - you must uncomment the XBEE_API2 line in and then rebuild the library.

The modules that are connected directly to libxbee should be configured in API mode 1 (see the AP command). In some cases this will require the correct firmware to be loaded - for example the XBee ZigBee modules.

Serial Interfacing

You must of course match the baudrate configuration between libxbee and the XBee module. Baudrates higher than 57600 have been repoted to have issues due to the error in clock division - I usually use 57600 baud.

libxbee expects to use hardware flow control (the RTS and CTS signals) by default. For this, the XBee modules must be configured correctly. These signals are usually present as a mode for Digital I/O pins 6 and 7 - see the D6 and D7 commands. I recommend that you use hardware flow control, however in some cases it is not a viable option. If you want to run without hardware flow control, you must uncomment the XBEE_NO_RTSCTS line in