The Arduino prototyping standard has been around for about 6 years now, and has proven to be immensely useful for sensing devices. It's the heart of the DustDuino and many other sensor nodes.
But for all the flexibility that the Arduino provides for collecting data about the environment, there still isn't a reasonably-priced, reliable shield to send data via WiFi.
The official Arduino WiFi shield, while well-supported, costs around $85. That's a pretty high price to connect a $4.50 chip to a network. Cheaper options such as the WiFly shield do exist, but some of the libraries supporting these devices are difficult to decipher or unstable, if they exist at all.
I spent a long time myself looking for a cheap, effective WiFi solution for the Arduino platform, and I've been very pleased with the $35 RN-XV module.
I like that this device isn't a shield, but rather is a module uses an XBee footprint. That means you can design your PCB to fit a tiny XBee-sized board, rather than design it around a bulky shield. So if you ever want to swap the RN-XV out for a different RF module (perhaps one with a range of 40 freaking miles).
You might require a shield to program it, the Arduino SD Wireless shield is a cheap add-on that, of course, allows you to integrate an SD card into your prototype at a later date.
And with a little electronics ingenuity, the RN-XV actually can transmit your sensor data without the assistance of a microcontroller.
I've only had minor trouble with RN-XV equipped Arduino sensors, relating to random hang-ups. I haven't done enough investigation to conclude whether it was the RN-XV or the ATMega microcontroller, though I had 100% success in preventing these hang-ups with a watchdog timer. The Harlequin library for this device, WiFlyHQ.cpp, has served me well.
The RN-XV does require some setup, but the payoff is you can set it and forget it. All that code (and precious bytes wasted) to connect to a wireless network, on each and every run through the loop? Throw it out, because this 'lil guy connects automatically. After you set it up, just tell it to send the data, and it does.
Here's how to set one up, using the SD Wireless Shield and the Arduino IDE:
- - With no shield attached, load a bare minimum sketch to Arduino UNO
- - Attach the RN-XV to the shield, and attach the shield to the UNO
- - Switch serial select on the shield to "USB"
- - Launch the Arduino IDE, and open serial monitor
- - Select "no line ending" in the serial monitor
- - Enter "$$$"
- - RN-XV will respond with "CMD"
- - Change serial monitor to "carriage return"
- - Send "set wlan ssid <id>" (when entering your network's ID here, substitute any spaces with the character "$")
- - Send "set wlan phrase <phrase>"
- - Send "save"
- - Send "reboot"
The RN-XV should return something like the following:
*Reboot*WiFly Ver 2.38, 12-11-2012 on RN-171
MAC Addr=##:##:##:##:##:##
Auto-Assoc ssid chan=5 mode=WPA2 SCAN OK
Joining ssid now..
*READY*
Associated!
DHCP: Start
DHCP in 3195ms, lease=86400s
IF=UP
DHCP=ON
IP=###.###.#.##:####
NM=###.###.###.#
GW=###.###.#.###
Listen on ####
If the red LED on your RN-XV dissapears after the reboot, congratulations! You've connected to the network.
But now that you're connected, you need to update your firmware. The RN-XV you've got probably has an out-of-date FTP address, so you'll need to update that, and the firmware, by doing the following:
- - send "$$$" to return to the command mode, if not already there.
- - send "set ftp address 0"
- - send "set dns backup rn.microchip.com"
- - send "save"
- - send "ftp update"
You should get something like the following:
<2 .38> FTP connecting to 198.175.253.161
FTP file=54
...............................................................
FTP OK.
UPDATE OK
Then:
- - send "save"
- - send "factory R"
- - send "reboot"
You should get something like the following:
<2 .38> reboot
*Reboot*wifly-EZX Ver 4.00.1, Apr 19 2013 11:47:16 on RN-171
MAC Addr=##:##:##:##:##:##
*READY*
The RN-XV will reboot to the factory settings, which means you'll have to go back and re-enter your ssid and passphrase. But it's a small price to pay for having your firmare in tip-top shape.
Now, time to load the actual sketch for your sensor node or what have you:
- - unplug your device from the computer
- - detach the shield from your Uno
- - program the Arduino Uno separately with your sketch
- - re-attach the shield with RN-XV, set serial select back to "micro"
- - plug into power source
- - enjoy!