Using the RN-XV WiFi Module as a Remote Switch
2011 December 20
It’s been a struggle, but I finally figured out how to use a Roving Networks RN-XV WiFi module as a remote switch. It’s not hard now that I know how it works, but figuring out was quite difficult, as the manual is apparently incorrect and the firmware it shipped with was causing problems. Read on for the solution!
Hardware
Simple! Here’s all you need:
- An XBee breakout board (so you can plug it into your breadboard)
- An XBee Explorer (not necessary with ad-hoc mode, but I had one around so this tutorial will use it)
- 3.3V regulator (ONLY—the module has a 10% tolerance, so anything beyond that will either not work or damage the module).
- 10µF and 0.1µF capacitors for good measure (clean power is especially important when using radio devices)
- Power and Ground (Pins 1 and 10, the top and bottom pins on the left side of the module)
- An LED connected to pin 9. In practice you’d want to put a current-limiting resistor on it, i.e. 220 ohms, but for a quick test it won’t matter. The module only drives 8mA on this pin.
- That’s it!
Setup
Although the module has an ad-hoc setup mode, where it broadcasts its own ad-hoc wifi network that you connect to with your computer, I found it faster to just plug it in directly to my computer using a serial adapter such as the XBee Explorer. When you connect with ad-hoc mode, you talk to the module over telnet, when you use direct serial, you use a serial terminal such as CoolTerm, which the following instructions will use.
With your module plugged into USB, open up the port in CoolTerm. You may see some data from the unit or a status message (it’s ok if you don’t). Type $$$ (without hitting return) to enter command mode. Now you can setup the module’s wifi settings (hit return after each command):
set wlan phrase <your wpa password> set wlan ssid <your ssid> save reboot
The module will power-cycle and the green status LED will start blinking. After 5-10 seconds it should start blinking more slowly, which indicates that it has successfully connected to your WiFi network. If your terminal session is still open, you should see a status message that indicates its success and its IP address (which you’ll need soon).
Now we need to update the firmware. Luckily, they made this extremely easy! Just do this:
ftp u
And it will take care of the rest—connecting to the Roving Networks FTP server, downloading the newest firmware image and ‘installing’ it.
Once that’s done, you can transfer your module to your breadboard. The rest of the work happens over telnet, so make sure your computer and module are connecting to the same WiFi network! When the module is on your board and it’s joined your network, open a shell on your computer and do:
telnet <module's ip address> 2000
You should see a ‘*HELLO*’ message. Congratulations! Now you can talk to your breadboarded module from anywhere! To switch the LED on and off, first set the I/O direction mask:
set sys mask 0x21f2
This adds GPIO (General-Purpose Input/Output) Pin 1 (hex 0×2) to the default mask, setting it as an output. To switch it high, do:
set sys output 2 2
Similarly, to switch it low:
set sys output 0 2
And that’s it! You can now, for instance, have a web server connect directly to that port and issue those commands dynamically to control your hardware remotely. Try hooking up a relay to switch a house light!
References
- RN-XV User Manual (API reference, etc.)
- RN-XV Datasheet (pinout and electrical characteristics)
Related Posts:
-
Orlando Castillo
-
gabriellalevine
-
Ted Hayes
-
poornima ambati
-
Adam
-
ahmad
-
ahmad
-
ahmad
-
ahmad
-
Cardinals Fan 2013
-
brazo de oro
-
Terminal_28
-
Brian
-
tom
-
Philip Tranter
-
Philip Tranter
-
ahmad
-
ahmad
-
Leonardo-rocha-porto
-
Chad
-
Ted Hayes
-
Cardinals Fan 2013
-
Rudy Van Nuffelen
-
Andy Beck
-
Fa_a2z
-
Fa_a2z
-
Keklja
-
http://log.liminastudio.com/ T3db0t
-
Keklja
-
Gethin Evans