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

DHCP: OFF
IP address: 169.254.1.1

Netmask: 255.255.0.0

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:

save

Otherwise, all is lost when you then type:

reboot

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.

31 Responses

Hey,
Do have any idea to connect arduino to the wifi board, arduino acting as a server hosting a web page and possibly I could connect through my iphone. All of this on adhoc mode.
Thanks

chris / 3-18-2012 / ·

Raza,
Sparkfun have a decent tutorial here, which covers getting the basic connection from the Arduino to the WiFly.
Once you have a simple web server up and running on the Arduino, you should be able to connect to it from any web enabled device: computer, phone, etc.

You might want to give the Arduino/WiFly a known IP address and join it to an existing wifi network though. It’s perfectly possible to just connect to it in ad-hoc mode, but I find it easier specifying it’s IP address myself.
C

Raza / 4-2-2012 / ·

Hey,
what I’m trying to do with the RNXV is to connect the wifly to my blackberry playbook and the wifly setup on the robot, and through an Blackberry app i can send commands to the wifly, What im stuck on is the part where we communicate with the wifly, for example it has an ip address given by the router, the connection between two devices is open- or two ports. I need to send some thing so that it triggers and communicates with the arduino.Im using the wifly library.
Any help is appreciated.

Bill / 3-18-2012 / ·

Clever play on words for the site name – I’m sure Le Carre himself would approve.

Zach / 4-3-2012 / ·

I am working on my senior design project and need to send data from an iPhone to my arduino through a wifly so that I can display that information on an OLED display.

Would you be able to help me accomplish this? I assume that I need to have it receiving UDP packets but frankly I am just not sure.

Thanks!

chris / 4-6-2012 / ·

Hi Zach,

Yes you might want to use UDP packets. I’ve not set mine up that way, so I won’t profess to be able to help you with that.

It sounds like you want to have a web server running on the arduino, I think the example sketches include a web server and a web client. You’ll probably want an SD card to store the data it’s receiving. As far as I remember, the Ethernet shield has an SD card slot.

What sort of data will you be sending to it? I’m guessing text strings or numerical values?

Hi Guys, I am new to ardiuno and wifly. I have a device that analyze water quality. I wan’t to see result on my computer.I connected the ardiuno and wifly and I did all ipconfig and telnet, I got Hello. Now what is next? I believe I need to wright a program which tells the micro to send the data! and I need a terminal software to display reading on my computer screen. I know I sound very hopeless but I really need a help

Aaron Eiche / 6-18-2012 / ·

Have you had any success communicating with the RN-XV over UART? Have you tried at all? I’ve been scratching my head trying to figure out how to talk to mine without going the ad-hoc route.

chris / 6-19-2012 / ·

Hi Aaron,
I haven’t tried yet to be honest. But I’ve got plans to use a dedicated Arduino with RN-XV in my garage to run a gas meter reader that’s just outside the garage door. So I’m sure I’ll have to figure it out at some point. Let me know if you strike gold!

C

Resurrection. « Deepwire's Blog / 9-18-2012 / ·

[…] […]

Win / 10-2-2012 / ·

Hi Chris
Thanks for the information. I followed your info whereby i used static IP. I can associate wirh my network but i cannot open the web page and get sensor info.
I key in static IP address in the browser, but it did not open. I try to telnet with Static IP &port 2000, it didnt work either.
Where am i wrong?
And how to combine above set up with arduino (without Wifly lib)? Do you have any sample sketch? If yes, please share with us.
Regards
Win

chris / 10-2-2012 / ·

Hi Win,
The WiFly runs as a web client, rather than as a web server. It doesn’t serve up any pages itself. I have mine making GET requests to a PHP web page on my local server. The WiFly appends the sensor data onto the end of the address that it’s requesting. The PHP script being requested strips the sensor data out of the request, does some conversion on it, and then puts it into a mySQL database.
I’ve not used mine with the Arduino yet. The main purpose of the WiFly, for me, was to set up a single device reading sensor data, and to keep it as cheap as possible. So I wanted to see if I could just use the WiFly on it’s own.

Good Luck!

Chris

Win / 10-3-2012 / ·

Hi Chris
Thanks for your clarification. Now i understand the set up and will try again.
Rgds
Win

Electric Imp / 10-9-2012 / ·

[…] It’s been set up by ex-Apple and Google people, with the aim of making ‘the internet of things’ more easy to configure. You teach the device the SSID and passphrase for your WiFi network by placing it on the screen of your Android or iOS phone, which then flashes the screen to transfer the data over. Sounds much more straightforward than setting up the WiFly RN-XV! […]

Wifly Working at Last! « dmt195 today / 1-29-2013 / ·

[…] After several attempts to get my Wifly-rn-xv working I’ve finally succeeded. The documentation seems good at first glance but when you get into it you realise information is missing. To be fair I got the initial connection working with a combination of the command datasheet and the following blog: http://www.tinkerfailure.com/2012/02/setting-up-the-wifly-rn-xv/ […]

atif / 3-30-2013 / ·

anyone had any success communicating with the RN-XV Tell me plz

Chris / 3-30-2013 / ·

Hi Atif.

Well, yes. I think a great many people have had success communicating with their RN-XV.

Are you having problems then?

Chris

atif / 3-31-2013 / ·

Hi Chris

yes i m having a problem in connection of Rn xv wireless with my laptop using teraterm. first time i had connected it well but when i connect my Rn xv with computer serially i have problems in its wireless connection .
Will u help me in that .

chris / 6-27-2013 / ·

Atif,

How did you connect it first time? When it worked?

C

LouisBourdon / 4-20-2013 / ·

Hi, good tutorial, I went through it, but Im still having problems to connect to my router – anybody that has an idea of why it is not working let me know! I use WiFly 2.21 RN-131C, Arduino Uno with IDE 1.0, and Apple Airport router.
I run the library WiFly Shield Master. The SpiUart Terminal sketch runs fine, I can set all the necessary commands, set IP address, WPA2 mode, SSID, passwords, and save everything. I see in the command line that the shield has been associated with the router. However, when I run the WiFly Web Client sketch, it prints out Association Failed. I have tried everything and still I get this error.
Can someone tell me if possible, why it can’t synchronize? So, frustrated!!!

chris / 6-27-2013 / ·

Louis,

Have you tried getting the RN-XV to connect on it’s own, without the Arduino?

C

doyajii1 / 4-25-2013 / ·

any one trying this arduino fio + rn-xv + wifly lib?

Tjaart / 6-20-2013 / ·

Hello

I was wondering if you could still use the UDP protocol for transfering data while in ad-hoc mode? I want to transmit data serially over WiFi, but I don’t want a router between my computer and the WiFi module will it be possible to do this way?

chris / 6-27-2013 / ·

Tjaart,

The important thing to remember is that when it’s in Ad-Hoc mode, the WiFly sets up it’s own WiFi network. The idea being that you join that network with your computer in order to program it. Then once it’s programmed to be able to connect to your own (main) WiFi network, you reboot it in ‘normal’ mode. And it connects!

So you could leave the WiFly in Ad-Hoc mode, and get your computer to connect to it occasionally to receive posted data. But it seems like the wrong way round to do it to me.

ATIF / 6-26-2013 / ·

Hey all

I m working with wifly module rn xv and i had done its communication with microcontroller now i wanna know that can i communicate between two rn xv and a laptop or pc.if it is possible then how?

» Getting started with the WiFly RN-XV as an HTTP Client The Machinist / 8-10-2013 / ·

well, i setup the wifly and – ok – its connected with my network,great 🙂
but how can i setup the wifly module so that i can send a string from my computer (via telnet…) to a microcontroller.does anyone have an idea how to do this in a simple way?
i would apreciate that!