Setting up the WiFly RN-XV

Setting up the WiFly RN-XV

What follows is a guide to setting up the RN-XV in the way I have – so it operates autonomously, connects to a wifi network periodically, posts it’s sensor data, and then disconnects. A few people have shown an interest in how I got it working, so I thought I’d share it here.

When I was considering buying a WiFly, I did a lot of searching for information on the web, and for details of other people’s experiences with the device. The main thing I noticed was that there seemed to be a large number of people who were struggling just to get the device connected in the first place, in order to then set it up properly.

Most folks seemed to be either using some kind of serial breakout board or cable, or connecting to it using an Arduino or similar prototyping platform. I wasn’t sure how I was going to go about it, but I ordered one anyway.

This page was last updated on Monday 28th January 2013.

I’m pretty weird in that I like reading instruction manuals. A couple of long flights I had to take for work meant I had plenty of time to peruse the RN-XV manual. This certainly made it seem easy to connect to the device wirelessly in order to set it up.

So when mine arrived, that’s what I tried first. I used the Arduino to supply the required 3.3V power, and connected a further cable to PIN8 on the RN-XV. This forces it to boot up in ad-hoc mode. Basically the device creates it’s own wifi network, that you can then log into.

The manual gives the following information about the network the RN-XV creates:

SSID: WiFly-GSX-XX, where XX is the final two bytes of the devices MAC address
Channel: 1
 IP address:
Pretty much all you need to know is the SSID. That’s the name the network advertises itself as. So all I did was find this in the WiFi menu on my iMac. It connected, and so I opened a terminal window. For those of you using a Windows machine, I’ve heard good things about TerraTerm, although I’ve never used it. I wasn’t sure the terminal would work, but I gave it a try.
All you do then is telnet into the ip address given by the manual:
We want to get into Command mode, so just type $$$ (as you can see in the image above) and hit return.
The main thing we want to do now is tell the RN-XV about your wifi network, and how to connect to it. So type the following, hitting return after each line:
set wlan phrase [your wpa passphrase]
set wlan ssid [the SSID of your wifi network]
This will mean the RN-XV can find and connect to your network, but you also need to think about the IP address the RN-XV will use.
If you’ve never fiddled with your home network or router, then you probably want the RN-XV to request an IP Address from the router (all routers have this function, it’s called DHCP – which stands for Dynamic Host Configuration Protocol). This means the router will assign the RN-XV an IP address whenever it asks for one.
If you have fiddled with your router (as I have), you might have set aside a chunk of IP addresses that are unavailable to DHCP. I personally have several devices I want or need to know the address of, so I have a load of addresses left available for me to assign them manually.
The easiest thing is to assign the RN-XV a static IP address. But as I say, if you haven’t fiddled with your router, or have no idea what this means, you should probably do all the setup whilst connected in ad-hoc mode. As once the RN-XV reboots, you’ll have to do some detective work to find out which address it’s using.
If you can give it a static IP address, do so now. Type this in the terminal and hit return:
set ip address [enter an IP address outside of your DHCP range]
If you do give it a static IP address, make sure to turn DHCP off:
set ip dhcp 0
Whether you give it a static IP or not, you need to tell the RN-XV some further things to make it’s life easy possible:
The address of your router
set ip gateway [IP address of your router]
The address of the server with the web page you’re going to use to receive your sensor data:
set ip host [IP Address of the server]
The port number of the server:
set ip remote 80
Set WLAN authorisation type (apparently not necessary, but I set mine to ‘4’ which is WPA2-PSK)
set wlan auth 4
Turn off the display of the WiFi password in the WiFly settings:
set wlan hide 1
Turn on TCP & HTTP mode:
set ip proto 18
Set the path to your ‘sensor data receiving script’ on the server:
set com remote GET$/thepage.php?DATA=
Tell the RN-XV to sample all the analogue sensor pins:
set q sensor 0xFF
Get the RN-XV to send an HTTP header, followed by the sensor data in HEX format:
set option format 7
Make it connect every 4 minutes or so:
set sys autoconn 250
Initially, I had this set to 300, but anything over 255 makes it connect immediately, over and over again.
Then, most importantly of all, type this:
Otherwise, all is lost when you then type:
It’s probably a good idea to unplug the lead from PIN8 before you do that, otherwise it’ll just start up in ad-hoc mode again…
If you assigned the device a static IP, you can now telnet into the device at the address you gave it. If you let it request it’s own IP Address via DHCP, then you have to hope it starts sending that sensor data to your server, or you’ll be sticking the wire back onto PIN8 and fiddling around in ad-hoc mode once again.