Arduino+ xBee + Processing

Making an Arduino Fio controlled through Processing via xbee is just a small part of a bigger project I was doing when I worked at Lancaster University as a Research Associate at the School of Computing and Communications. Things that you will need:

2 xbee antennas ( I used the pro series 1)
2 xbee usb explorers
1 arduino fio
2 USB 2.0 type A to Mini-B 5-pin cables
1 ftdi to usb serial cable
soldering iron
breakaway headers

Processing IDE
Arduino IDE


The Arduino Fio comes without presoldered breakaway headers. So in order to program it using the ftdi cable, I soldered 6 breakaway headers. Of course you can try and program the antennas wirelessly but I haven’t tried it so I can’t help you there. In the usb xbee explorer you should also solder a small jumper wire between RTS and DIO3. I don’t know why but this is how it should be done.

arduino fio soldered

xbee explorer soldered

Programming the Xbees

This was for me the trickiest part. I thought that I had to use the X-CTU AND the Xbee configuration tool AND a serial terminal application like Coolterm. I realized that you actually these are just 3 different programms that do the same thing. So you only have to use ONE of them to program your Xbees. I would suggest you to use the X-CTU. There is a good reason for that and I will explain it later. XCTU gives you more tweaking capabilities (you can tweak all the parameters of an Xbee radio. Which are a lot!). So here I will describe how to tweak them with Xbee configuration tool.
-Plug your Xbee antenna on the Xbee explorer. If you don’t know how your Xbee should be mounted on your xbee explorer, the white lines at the top of the xbee explorer, opposite the mini usb socket will tell you how (check your xbee explorer: one side has the mini usb socket, the other side has two white lines that if projected would form an angle. So this is how to mount the xbee antenna on your xbee explorer.Basically the flat side of the xbee should be above the mini usb socket as you can see in the photo. 😉 ). If you hook it the other way, it will not work. If by mistake one of pins of your xbee antenna is ahead or behind the female headers of your xbee explorer, again it will not work, when you will try to program the antennas.

– Download and install Digi X-CTU software from here.
– Plug the xbee antenna to the xbee explorer. You should keep in mind that one your antennas at the end of the project will be seated on an xbee explorer connected to your computer via the usb cable (that is your programming radio) and the other one will be seated on the arduino fio (that is your arduino fio radio). It is better to tag them with some tape or something in order not to mix them up and to know which one you are going to programme, if you ever need to reprogramme them through XCTU (trust me. I did it many times until I managed to program them successfully).
-Connect the xbee explorer to the computer with the mini usb cable. Assumed that you have worked before with Arduinos you don’t need to download and install the ftdi drivers. If you need to, then download and install the ftdi drivers too. If the ftdi drivers are already installed in your computer, then a communication port will be assigned to the usb xbee explorer as soon as you have plugged it to your computer. You can see which one going to the device manager control panel-> hardware and sound -> device manager -> Ports (COM & LPT)
– Open the XCTU software and choose the assigned Com Port from the Select Com Port list on the top left of the software.
-My port is COM4. I have set the baudrate to 57600, Flow control NONE, Data Bits 8, Parity NONE and Stop Bits 1. Press the Test/ Query button. If everything is alright then a pop up window appears which will confirm that the communication with the xbee explorer is OK, it will show the type of the xbee antenna and the installed firmware. Press OK. If you get a message “Unable to open comm port”, make sure that the Xbee antenna is seated properly on the xbee explorer sockets and not backwards. Double check if you have selected the correct comport in the X-CTU.
– Click the Modem Configuration tab. In the Modem Parameters and Firmware, press Read. That should show you the Modem type (in my case XBP24), the Function Set (Xbee pro 802.15.4) and the firmware version (10E8). Press the Download new versions. XCTU will download the latest versions of the firmware. You can choose to install a more recent Firmware for your xbee Antennas. Be sure that you install the same version of Firmware to both Antennas to be programmed.Press Read again.
– The first xbee Antenna to be programmed is the one which is later going to be connected to the computer(from now one referred to as Computer Xbee). The next one to be programmed will be the one connected to the Arduino Fio (from now on referred to as Arduino Fio xbee). Now we are ready to program the Computer xbee. The table presents the configuration of the computer xbee on the left and the configuration of the Arduino Fio Xbee on the right.

Xbee Computer Arduino Fio xbee
PAN ID 4289 4289
DL FFFF 0 (zero)
MY 0 (zero) 1
SH 12A600 12A600
BD 6 6
RO 10 10
AP 2 0 (zero)
D3 3 5
IU 0 (zero) 0 (zero)
IC 8 0 (zero)
DD 10000 10000

-The SH and SL parameters in my table are numbers I made up based on the actual numbers of my xbees. You shouldn’t change your SH and SL. The SH and SL of the xbees are also written at the back of the xbee antennas.
– When you have changed the parameters to the Computer Xbee press Write. The changes will be uploaded to the xbee antenna and you should see the xbee explorer blinking. If you get a message “Action required. Unable to communicate with modem.”, remove the xbee antenna carefully from the xbee explorer and plug it back on it. You should see the LEDs at the back of the xbee explorer blinking showing that the changes in parameters are being uploaded. If not repeat the action. After the changes have been uploaded, take the xbee antenna off and place the other one that is going to be connected to the Arduino Fio later. Read its parameters, do the changes and press write again.
– I used X-CTU because the other two software do not allow you (I think) to set the Computer Xbee to API 2. Without setting the Computer Xbee to API 2 the control of the Fio through Processing is not going to work. (Robert Faludi, Building Wireeless Sensor Networks, pp 144).
– If you want to control the Arduino Fio from your computer through the Processing environment, then you need to upload to the arduino fio the special firmata version for Arduino FIO. Unfortunately the common firmata version will not work for Arduino Fio. You can find the special Firmata Version for Arduino Fio here. Unzip the folder. Go to hardware->fio->firmware->StandardFirmataForFio and upload the StandardFirmataForFio.pde file to your Arduino Fio (connect your arduino fio to the computer with the ftdi to usb cable. open the Arduino IDE, compile and upload the file to the Arduino Fio after you have selected the right Arduino board and Com port). I think I experienced a problem with the Arduino IDE version 1.0 when I tried to upload the StandardFirmataForFio.pde to the Arduino Fio board (the latest version of the Arduino IDE was giving me an error so I used the 0018 version of the Arduino IDE in the end).
– Almost there. Find where you have installed your Processing IDE in your computer. Find the library folder (it should be in Processing 1.x.x->modes->java->libraries). Create a folder named funnel inside the library folder of Processing. Copy and paste in the funnel folder you just created the library and examples folders you will find at funnel-1.xrxxx->libraries->processing->funnel (that’s the file you have just downloaded).
– In Processing 1.x.x->modes->java->libraries -> funnel -> library there is a .txt file named settings.fio.txt . Open it with Notepad or Worpad (but NOT with Openoffice or Libreoffice text editors). Insert the communication port and the baudrate as it is declared in X-CTU.


Last step. You also need to start the funnel server. Go to the funnel 1.0-r80x folder you have already downloaded and go to this path; funnel 1.0-r80x ->server -> windows -> funnel_server-win -> and click on the Funnel Server. You will need to choose the comm port the arduino Fio’s are communicating from the drop down menu on the right and the hardware/ firmware you are using (I think I chose the “Arduino FIO (standardfirmataforfio, baudrate 57600)” option to make mine work but it’s been a while so I am not sure. Well… You can experiment with that). *

Here is the code that you need in Processing in order to control the Arduino FIO through Processing. The code should blink an LED connected to the DigitalPin2 of the Arduino Fio for one second.

import processing.funnel.i2c.*;
import processing.funnel.*;
import processing.serial.*;

//fio variables
Fio fio;
int ledPinNumber1 = 2; //DigitalPin2
Pin ledPin1; // DigitalPin2

void setup (){
//start the fio and declare the I/O pins

int[] fioIDs = {1};
Configuration config = Fio.FIRMATA;
config.setDigitalPinMode(ledPinNumber1, Fio.OUT);
fio = new Fio(this, fioIDs, config);
ledPin1 = fio.iomodule(1).digitalPin(ledPinNumber1);


void draw () {
ledPin1.value = 1.0;
ledPin1.value = 0.0;
ledPin1.value = 1.0;
ledPin1.value = 0.0;
Good luck!

If you found what you read helpful or inspiring, the least you can do out of academic or research courtesy is to mention my website or my name when using the code or information from here.

Thank you!

* You can find some more information of how to setup the xbees and the arduino in the installation_instructions_en.pdf file you will find in funnel-1.0r80x -> documents folder.

Categories: Projects