Wireless Connection Using XBees (Arduino – MaxMSP)


This documentation explains how to set up a working wireless connection between an Arduino Circuit and a computer, using the popular XBee Radios. On a computer side, a Jitter patch is running on MaxMSP application. This application is going to talk to an Arduino Circuit that is sending values from its attached sensors. Hopefully they can talk to each other without any wires between them!

NYU ITP Xbee Basic Page
Artist Collective working extensively with Xbees (Has good references overall)
ashleyhughesarduino Site (Very good explanation on CoolTerm use)

Wired to Wireless

I have successfully established a serial communication between an arduino circuit and a Jitter patch on a Mac. For the serial communication, my Arduino circuit is connected to the Mac via a USB cable. Problem is that my Mac is also connected to a projector and there are too many wires! I’d like to remove the USB cable so that the computer and the projector can stay together and Arduino circuit can be placed with some distance from them.

So, currently this is how the system looks.
And I’d like to change it to something like this.
Why not Bluetooth?
My trial with Bluesmirf was not so successful. It could very well be because of my ignorance but it seemed that I had to establish the pairing between the circuit and the computer every time. In other words, it didn’t support plug and play (for me). 🙁 I wanted the serial communication to be simpler and easier, just like any other USB communication so I thought of giving it a shot at XBees, to see if it works better for my purpose.


Software Side
A Computer with
1. Arduino Software Installed
2. In my case, Max MSP Jitter Installed
3. FTDI Driver Installed
4. Coolterm Installed

Above is the software setup for my mac. If you have a(n extra) PC with you, it’s good to have X-CTU software (PC only) installed for troubleshooting. But you won’t need it unless your Xbees dont seem to respond, so let’s not worry about it right now.

Hardware Side

1. Arduino Unit with some breadboards, sensors, wires, a power adapter and a USB cable.
I have an Arduino Diecimila.
(Photo from Sparkfun)
2. Two XBee Radios (One for Mac, One for Arduino Board). Apparently, there are many different Xbees available. It seems that Series 1 is generally easier to use than Series 2, although I don’t know how it differs from each other in detail.
I got two XBee Pro 60mW Chip Antenna – Series 1. ($37.95/each)
3. One Xbee Adapter or Shield: One frustrating thing is that Xbee comes with pins with 2mm spacing, which doesn’t fit the usual 0.1 inch pin spacing of Breadboards. Simply, the Xbee would not be plugged into the prototype Breadboard, unless you solder wires into each pin or convert the spacing using these adapters. I got Parallax XBee Adapter Board from Jameco, because it’s cheaper($3.59) than other already built unit and this Jameco item comes with the 0.1″ headers so I didn’t have to order any other items to build the adapter.
One downside is that you have to solder a total of 42 pins ( (10+11)x2 ) that are spaced very narrowly and it takes some time and skills to do it correctly. This document shows how to solder the pins but in I found that it’s easier to solder the 11 pin headers before getting into the narrower 2 mm sockets.

Here, I’m including the wiring of Xbee Adapter to Arduino, since the 10 pins (XBee) to 11 pins (Apapter) conversion was a little bit confusing to me. You can click it to see a bigger image.

If you are not interested in building this, you can get an XBee Shield, ($19.95) which you can directly mount on top of your Arduino Unit. This sparkfun product doesn’t come with 0.1″ headers, so you have to order them together, unless you already have them.

4. One USB Dongle to plug in an XBee to the computer. There are ready made USB Dongles such as XBee Explorer USB from Sparkfun or USB-XBEE-DONGLE-CARRIER from New Micros. (Reference: http://www.kobakant.at/DIY/?p=204) Or, you can make one yourself, using FTDI breakout board. Unlike the XBee adapter, I didn’t want to build my own Xbee dongle, knowing that it’ll just cost me more time in the end. I decided to use Sparkfun’s Xbee Explorer($24.95), because it’s cheaper than New Micro’s ($39.0) and I already have a few USB A to B cables from my old digital cameras.

Now, let’s get onto the Xbee configuration!

Xbee Configuration (This part not complete)

1. First, let’s connect one Xbee to Mac using Xbee Explorer.
2. Open up a Coolterm application and Configure the Xbee. In fact, this part is so well covered in ashleyhughesarduino page, so I recommend you to please follow the page’s instruction on Xbee configuration.
Among everything that counts:
– Both Xbees should have the same Pan ID(ATID).
– Make sure “My address” (ATMY) and “Destination address” (ATDL) are pointing each other correctly. For example, if you set Xbee0’s my address to 0 and destination address to 1, then Xbee1’s my address should be 1 and destination address should be 0.
3. When you are done configuring, plug one Xbee to the Xbee adapter. Make sure the other Xbee is connected to your Mac via the Xbee explorer.

Check the serial communication using a serial monitor

1. To check whether the Xbee wireless serial communication is working, open up a serial monitor from Arduino software. Make sure you choose the correct Serial Port for Xbee Explorer under Tool-> Serial Port. If you previously had a working Arduino Code getting the serial data, then you should be able to see that your Xbee Wireless module is successfully replacing your USB serial connection.

Code to get the serial data in (Arduino – MaxMSP)(This part not complete yet)

This is for people who are curious how to code the arduino to get the serial data in.
1. In my case, I am interfacing Arduino to MaxMSP, so I got the sample code from this Arduino + MAX/MSP page. Among the examples, I used the code from Arduino2Max (Version .5) example. Arduino Code and a max patch was included as a part of the example package. I made a few changes to the arduino code and the Max Patch (Code by Daniel Jolliffe, based on Thomas Ouellet Fredericks’s original work) to make things simpler and meet my own needs. You may just use the original code provided from the above link.
– This is the code I used. In my circuit, I had four digital inputs (switches) connected to 2-5 pins of Arduino, and one LED is connected to pin 13. (Here, Arduino Code will be included and explained)
– You can download my arduino code and max patch here (Here, sample code will be zipped and included so people can download)
2. After you uploaded the code to arduino, open up the arduino serial monitor to see if you are successfully seeing the serial data displayed. If so, close arduino program and open up a MaxMSP patch that comes with my example to see if you can get the data into MaxMSP as well.
3. (Here, explain the max patch, if necessary)