The Arduino Fio is a nice little Arduino board designed specifically to interface with XBee devices. I think it’s a great little board and have used it quite a bit in the past. BUT, I haven’t talked too much about the XBee interface, so for this post, I wanted to demonstrate an example utilizing the XBee socket to get an Arduino Fio onto the web. This is a simple example, just demonstrating communication with the Microchip RN171XV (previously Roving Networks RN-XV) wifi module.
Click through the break for information on the setup and source code to get the Arduino Fio onto the web.
The project uses an Arduino Fio as the microcontroller, a Microchip RN171XV wifi module to connect to the internet (hereafter described using the old part name, RN-XV), and a Mini12864 graphical LCD to show debug information. Here’s a part list for this project (assuming you already have a USB -> Micro USB cable):
- Arduino Fio (available on Amazon & Sparkfun)
- Mini12864 graphical LCD (available on Amazon & DX)
- Microchip RN171XV/Roving Networks RN-XV (available on Amazon & Sparkfun)
- XBee USB adapter – for programming RN-XV (available on Amazon, DX, & SparkFun)
- FTDI 3.3V USB cable – for programming Fio (available on Amazon, DX, & SparkFun)
Want to make it completely wireless? I also used a Lithium Ion Polymer battery (available at Sparkfun).
When you first get the RN-XV, it needs to be updated to the latest firmware. First, it needs to be plugged into the XBee USB adapter and connected to your computer. These days, I’m working on a Mac, so I use CoolTerm to communicate with the RN-XV. Here are the settings (basically 9600 baud serial communication):
Then the RN-XV needs to be connected to your wireless access point and updated. Type in
$$$ to enter the command mode and you should see the RN-XV respond
CMD. You can then enter the commands one by one (carriage returns after each line) to connect the RN-XV to your WiFi access point. Here is my basic setup (see the RN-XV datasheet for additional information):
set wlan auth 4
set wlan ssid XXXX
set wlan phrase XXXX
set wlan join 1
The RN-XV should associate (connect) with your wifi network and then you can test the connectivity by pinging the Microchip FTP server:
ping 220.127.116.11 10
Then, update the RN-XV to the latest firmware (4.00.1 as of this article’s publish date):
set ftp address 18.104.22.168
set ftp user roving
set ftp pass Pass123
Once the update downloads, you can reset the factory defaults and reboot:
After the RN-XV resets, you should again enter the basic setup information to get the RN-XV connected to your WiFi access point (see above). If all works out, then you can disconnect the serial port and pull the RN-XV out of the XBee adapter for the time being (don’t put it into the Arduino Fio, because the Fio needs to be programmed and the TX/RX lines are shared on the board).
I found a wonderful Arduino library for the RN-XV called WiFlyHQ by harlequin-tech. The author includes a number of great examples, including a HTTP client, HTTP server, TCP client, UDP client, and web socket client. Using the basic setup code in the HTTP client example, I added code from my previous Arduino FIO Graphical LCD Console to make a simple “clock” that updates approximately every 3 seconds using the time-c.nist.gov time server. I used the console code because it allows for very simple debug printing (since the Fio’s serial TX/RX pins are shared with the XBee socket). Here an admittedly boring short video illustrating the “clock” being startup and allowed to run (the value on the far left is an indicator of the wireless signal strength, RSSI):
And finally, here’s the Arduino sketch: