Sensors & Time: Wireless Frisbee w/Attitude
I thought I’d try out my new XBees with the ADXL335 accelerometer I had on hand to make a 3-axis accelerometer visualization. I borrowed from project 21 in Tom’s Making Things Talk, but taped the accelerometer at the center of a frisbee (level to the frisbee’s orientation plane), along with an Arduino and an XBee. I added 4 LEDs: 2 placed on the two points where the x-axis of the accelerometer intercepts with the frisbee’s circumference and 2 on where the y-axis intercepts. I then programed the Arduino to illuminate the LEDs which corresponded to positive pitch or roll. I added an XBee to make it wireless and transmitted the acceleration (in gs) of the three axes, along with the pitch and yaw. I used processing to sketch a visualization of this data. The ellipses in the graph move vertically along their acceleration (in gs) axes. The orientation of the disc in the center (representing the frisbee) corresponds with the calculated pitch and roll of the accelerometer.
Build details below:
- 2 XBees (Series 1)
- 2 Adafruit XBee adaptors
- 1 FTDI cable
- 1 ADXL335 Accelerometer
- 1 Arduino Duemilanove
- 1 9V battery and clip w/ plug
- 4 super-bright blue LEDS
- Frisbee
You need a PC to update the firmware on the XBees, but I used them straight out of the box for this simple example.
- Download and install the drivers for the FTDI here (I used v. 2.2.16 for my Mac).
- Download CoolTerm (serial port terminal application).
- Program each XBee module with CoolTerm via the FTDI cable (see below).
- Upload the sketch below to the Arduino.
- Connect receiving XBee module and adaptor to your computer via the FTDI cable.
- Connect the transmitting XBee module, adaptor, and accelerometer to the battery powered Arduino (see schematic and photo below).
- Run the processing sketch below (make sure the serial monitor is closed).
Programming XBee modules with CoolTerm:
Each XBee module, the transmitter (which will transmit the serial data from the Arduino) and the receiver (which will receive this serial data and pass it along to the computer via the FTDI cable), need to be programmed. CoolTerm is a serial port terminal program that makes this process pretty painless.
1.) Connect the Transmitting Xbee and adaptor to a USB port via the FTDI cable.
2.) Open up CoolTerm
3.) Click Options and, under “Serial Port”, select the appropriate usbserial port (re-scan serial ports if you do not see the usbserial listed) and make sure that ’Baudrate’ is set to 9600, the ‘Databits’ to 8, and ‘Stop Bits’ to 1. Also, make sure “Local Echo” is checked under terminal (this will show the serial data coming in via the connected port in the CoolTerm window, which comes in handy when you need to verify your setup). Click “OK” to exit the option window.
4.) Click “Connect” to allow CoolTerm to communicate with the XBee.
5.) The commands below are entered into the CoolTerm window and assign the XBee an address, a destination address, and a Personal Area network ID.:
- Type ‘+++’, do not press enter, and wait for the XBee to respond with OK.
- Type ‘ATMY1′ and press enter. (This sets the address of the XBee we are programming, the transmitter, to 1.)
- Type ‘ATDL2′ and press enter. (This tells the XBee that we are programming, the transmitter, that the address for our destination XBee, the receiver, will be 2).
- Type ‘ATID2012′ and press enter. (This sets the Personal Area Network ID for the XBee. Since we want the XBees to communicate with each other, the other XBee will be set to the same PAN ID.)
- Type ‘ATWR’ and press enter. (This writes what was entered into the XBees memory).
- Click ‘Disconnect’.
Next, swap the transmitting XBee with the receiving XBee.
1.) Swap the transmitting XBee (this will later be connected to the Arduino and the accelerometer, but leave it aside for now) connected via the FTDI cable with the Receiving XBee.
2.) Click “Connect” to allow CoolTerm to communicate with the receiving XBee.
5.) The commands below are identical to the previous XBee, except the address and destination address are swapped.:
- Type ‘+++’, do not press enter, and wait for the XBee to respond with OK.
- Type ‘ATMY2′ and press enter. (This sets the address of the XBee we are programming, the receiver, to 2).
- Type ‘ATDL1′ and press enter. (This tells the XBee that we are programming, the receiver, that the address for our sending XBee, the transmitter, is 1).
- Type ‘ATID2012′ and press enter. (This is the same Personal Area Network ID set for the transmitting XBee.)
- Type ‘ATWR’ and press enter. (This writes what has been entered into the XBees memory).
- Click ‘Disconnect’ and remove the FTDI cable from the computer.
Now that the XBees are programmed, program the Arduino.
The Arduino serves two functions:
- It supplies 3.3V to the transmitting XBee and the accelerometer.
- It will also read the X, Y, and Z output, as analog input, from the accelerometer, and convert this into “pitch” and “roll” serial data to send to the XBee via TX.
The following sketch is based on Project 21: “Determining Attitude Using as Accelerometer” from Tom Igoe’s Making Things Talk.
Upload the following sketch to the Arduino, disconnecting the Arduino from the computer after the sketch has been successfully uploaded.
Now that the XBees and the Arduino have been programmed, it’s time to wire up.


