Getting started with the WiFly RN-XV as an HTTP Client

Introduction

Recently, I started a project which requires wireless data transmission. I am reading output from a Digital Caliper using an Arduino and transmitting the data to a server for storage and tracking. Because I wanted 802.11 compatibility I chose the Roving Network’s WiFly module, specifically the WiFly RN-XV (Datasheet) which I purchased from SparkFun. The WiFly module provides 802.11b/g Here is the parts list for my setup:

There are a couple of steps to get you from shiny new RN-XV to data on your server. Wiring the hardware and programming is beyond the scope of this tutorial. So here is a road-map of the things we are going to cover.

Road-map

  1. Connecting to a nearby WiFi network
  2. Assigning a static IP address to the module (optional)
  3. Firmware update (important)
  4. Configure the RN-XV to act as an HTTP Client
  5. A short script for your web server.

Personally, this was the first time I had to soder anything together. If it is also your first time: be patient! Here is a tip: Instead of heating the soder and trying to place it on the pin. Heat the pin with the iron and touch the soder to the pin.

 

Connect to a network

Before we can update the firmware we have expose our WiFly module to the wide open Internet. To accomplish this we have to connect the WiFly module to our WiFi Network. The process is pretty straight-forward:

Authentication Mode
0 Open (Default)
1 WEP-128
2 WPA1
3 Mixed WPA1 and WPA2-PSK
4 WPA2-PSK
6 Ad hoc mode
8 WPE-64
set ip dhcp 1
set wlan join 0
set wlan ssid [WifiNetworkName]
set wlan phrase [password]
set wlan auth [see auth table]
scan (this will output a table of nearby 
  networks tagged with a number)
join [#]
save

 

Updating the Firmware

The latest version of the Firmware as of this writing is 4.0. Upgrading to 4.0 with my Firmware (2.38) was very easy. Here are the commands:

ftp update WiFly-7.400.mif
factory RESET
reboot

With my firmware (2.38) the update process was smooth, though I’ve read older models may come with the wrong DNS information.

If you receive this error:

530 Login Authentication failed

Then you may need update the address of the server. Use the following commands:

set ftp address 0
set ftp dns name rn.microchip.com
save

Setting a static IP address

There are reasons you may want to assign a static IP address to your device. If you are not sure what this means, don’t worry about it. This step is completely optional:

set ip dhcp 0 (turn off dhcp, it's unnecessary 
  since we are assigning an address)
set ip address [xxx.xx.xx.xxx]
set ip gateway [xxx.xxx.xxx.x]
save
reboot

Configuring the WiFly to send data to a web server

So, if you’re like me and you are interfacing your WiFly with a microcontroller then you will probably be sending information to the WiFly via the UART. Using the serial interface on the WiFly is simple because you only need to connect the Rx and Tx lines. In my configuration I want to send the information written to the serial interface to a script on my web server.

set ip proto 18 (TCP/HTTP mode)
set option format 1 (Send an HTML Header)
set ip host 0 (Turn on DNS)
set ip remote 80 (Set the port the server is listening on)
set com remote [{Request Type}${/Request URL}
set uart mode 2 (Send a request when data is written to the serial port)
save

When you set the remote URL you have to use the command character instead of spaces otherwise you will truncate the line. So your remote address should look sort of like this:

set com remote GET$/myscript.php?data=

Now when you write a line to the serial interface, it will send an HTTP request to your web server. I’ve noticed with this configuration that you may need to use a domain. I tried sending data to a local IP address that is being monitored by netcat but for some reason I couldn’t ever get it to connect. If someone has more information about that behavior I’d be happy to hear it.

If you’re interested in more reading I found these links helpful:

Setting Up The WiFly RN-XV from Tinker, Failure, Solder, Why?
WiFly Command Reference, Advanced Features & Applications User’s Guide
RN-XV Data Sheet

Comments
One Response to “Getting started with the WiFly RN-XV as an HTTP Client”
Trackbacks
Check out what others are saying...


Leave a Reply

Your email address will not be published. Required fields are marked *