How to configure an XBee on Linux, Mac, or any other operating system
Consider this post a corrective to all the over-complicated advice I’ve seen out there.
If you own an XBee, you likely already know that the official configuration tool, X-CTU, only runs on Windows. As result, if you need to configure an XBee on a different operating system, a Google search brings up repeated suggestions to install a Windows emulator, install X-CTU, then manually update some drivers.
Now this is fine if you already have or want an emulator but really…there is no need for such a heavy-weight solution. You can fully configure your XBee via the serial port and a terminal program.
Windows comes with Hyperterminal pre-installed, but for Linux I downloaded the free minicom program. (Mac…you are on your own.) Before starting, you need to know the port the XBee is attached to and the communication settings, just as you would with X-CTU. For a factory-fresh XBee, the communication settings will be:
- baud rate: 960
- data bits: 8
- parity: None
- stop bits: 1
- hardware flow control: None
To find the port the XBee is using, follow the directions for your operating system: for Linux udevadm, or on Windows it is Device Manager.
For Linux minicom, I recommend the terminal options of turning on local echo and adding linefeeds.
Once your terminal program is up and running, open the connection to your XBee port. Type the string +++ quickly without pressing the Enter key. You should get back a reply of “OK” from the XBee. If it doesn’t work, wait 10 seconds and try again. If it fails repeatedly, you may be at the wrong communication settings. Usually it is a matter of mismatched baud rate. But if you’ve totally forgotten the XBee settings, you can use this simple method to do a hardware XBee factory reset.
After you’ve gotten the OK, type
AT
You should get another OK back. +++ and AT put the XBee into command mode. This is a temporary state! For the next few seconds any information sent to the serial port will be used to command the XBee, and the XBee will not forward it on to any listeners.
The most common change is that of baud rate. Type
ATBD
The XBee will reply back with 3, which equates to a baud rate of 9600. Let’s say that we want to increase this to 57600. We type in
ATBD 6
and get back OK. To write the change to the XBee’s memory, type
ATWR
At this point, the XBee will be communicating at 57600 baud, so you must change the communication settings in your terminal program in order to continue.
If you ever have to pause and figure out what you are doing, just type +++ again to put the XBee back into command mode.
Another common change is PAN ID. XBees ship with a default PAN ID and you will want to avoid crosstalk with other people’s networks. The command for this is ATID. As before, issuing a plain ATID tells you the current value (probably 1332) and sending a command like ATID 1414 will change the PAN ID to 1414.
There is a full list of XBee configuration commands in the XBee User’s Guide, Chapter 10.
In writing this post I learned about the moltosenso IRON, a free cross-platform alternative to X-CTU. I have not tried it, but it might be useful for those who need to do more complicated configurations.
On a Mac, you just open Terminal. Its location is Applications > Utilities > Terminal.app, but if you didn’t know that, you probably shouldn’t be playing with it…
Thanks, Julie!