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: 9600
- 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!
Phew, your comment alomst ended up mixed in with a barrage of new comment spam, but I’m glad I found it and could take a quick look at your blog too.Yes, I ended up stepping down the signal line to 3.3v with a voltage divider. However, sometimes the commands from the XBee to the Roomba did not work, and I’ve put that down to that the 3.3v signal isn’t enough to produce a logic level change in the 5v Roomba, and I haven’t had time to look at stepping up this 3.3 -> 5v since playing with it months back, although CMOS and TTL logic say 3.3v should be enough. If you get that little circuit going, let me know! I was thinking of adding a transistor to drive the 5v signal line with the base connected to the 3.3v XBee signal.
As a footnote, on MacOSX, Coolterm is a very good choice, with a simple and intuitive GUI and esay installation. Incidentaly, it’s also available for Linux and Windows. I mainly use it for config if I can’t get to X-CTU.
how do u config the xbees via terminal??
I don’t have a Mac or terminal but the AT commands should be identical.
Hi, Can I configure a XBEE as a coordinator, router or end device via terminal too without X CTU?
There are various tools for use with XBEE; I would explore and see what you can find.
Great stuff. Totally stuffed with x-ctu on Windows as I am totally blind and it doesn’t work with my open source screen-reader (NVDA). Most Qt apps don’t. But this works fine on Linux with picocom