Skip to content

Using the RN-XV WiFi Module as a Remote Switch

2011 December 20
by Tedb0t

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!


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!
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>


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 0x2) 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!


Related Posts:

41 Responses
  1. Orlando Castillo permalink
    December 20, 2011

    Thank you so much for this super precise tutorial… it was so hard to filter out what was necessary from the manual! They should link to this tutorial on the Sparkfun RN-XV product page.

    • December 20, 2011

      Awesome! Glad I could help! 😀

      • gabriellalevine permalink
        July 28, 2012

        Hey Ted! I’m trying now your tutorial with the rnxv but when i’m trying to update the firmware i get:
        ftp u

        FTP connecting to
        FTP timeout=2

        and also, when I telnet, I’m not getting “hello” I’m getting:
        gabriellas-MacBook-Air:~ gabriellalevine$ telnet “” 2000Trying…Connected to character is ‘^]’.Connection closed by foreign host.gabriellas-MacBook-Air:~ gabriellalevine$

        Do you have any idea..? I’m going to keep trying but I just started?

        • Ted Hayes permalink
          July 29, 2012

          Yeah I get that timeout also. Really frustrating >:-| check here though:

          the “hello” is configurable, so your module may have had that setting changed at some point (one of the arduino libraries does change it intentionally). Does it not stay connected once you connect? Are you able to issue any commands?

          • poornima ambati permalink
            May 3, 2013

            HI, I am new to the rn-171 we are using ufl connector for external antenna, and i am interfacing through uart to the tera term, I am able to going for the command mode but my module ssid is not coming under ssid list of mt laptop i thin k i have problem with the antenna can you please give the comments.

      • Adam permalink
        September 24, 2012

        Hi Bro can you post here schematic of this?
        i dont want destroy my modem:)

  2. ahmad permalink
    December 21, 2011

    first of all, thanks very much for this. your last tutorial (node.js + rn-xv) really helped me get the WiFly GSX Breakout working.

    for some reason it didn’t help me with the rn-xv. did you have to perform this same firmware upgrade in both cases? maybe that’s what i was missing

    • December 21, 2011

      When I wrote the Node tutorial I hadn’t upgraded the firmware yet but it was working fine. This time, however, I had lots of problems and the firmware update seemed to fix it, but I still have problems on other networks—it seems very touchy about WiFi routers and security settings.

      • ahmad permalink
        December 21, 2011

        yeah these wi-fi modules have caused me (and everyone by the looks of it) great frustration, but getting it working eventually is amazing.

        i still have issues with the GSX freezing on every 5th or 6th incoming request.

        a friend was telling me that most of these modules just don’t work on enterprise level WPA2 networks, like the one i have at work.

        i guess they’re a bit flaky but with tutorial contributions like yours, we’ll get there! thanks.

  3. ahmad permalink
    December 21, 2011

    so i’m having trouble getting the rn-xv into command mode.

    i have 3.3V, GND, TX, and RX connected.
    i’m able to connect to it in CoolTerm and I get the following output:

    .WiFly Ver 2.30, 10-26-2011 on RN-171
    MAC Addr=00:06:66:71:1a:ba
    Auto-Assoc roving1 chan=0 mode=NONE FAILED
    Auto-Assoc roving1 chan=0 mode=NONE FAILED
    Auto-Assoc roving1 chan=0 mode=NONE FAILED
    Auto-Assoc roving1 chan=0 mode=NONE FAILED

    I’ve tried many different ways of sending it $$$, but nothing happens except every few seconds i get another line of this:
    Auto-Assoc roving1 chan=0 mode=NONE FAILED

    I tried just typing $$$ in CoolTerm. As expected, on every $ typed, I see the DIN or tx light blink on the xbee regulated, as expected.

    I also tried “Send String…” with no return carriage, still no luck.

    How exactly do you send the $$$ and the other commands. Did you change any of the CoolTerm options from the defaults? It’s probably something obvious that i’m missing… any help would be greatly appreciated!

    • ahmad permalink
      December 21, 2011

      ok, the following steps seemed to work better for me:

      1. In addition to the above connections, also connect PIO9 (pin 8) to 3.3V
      2. Recycle power, since PIO9 is high, it goes into ADHOC mode
      3. Connect to the “WiFly” ssid from my laptop
      4. Telnet to the IPAddress
      You should now see *HELLO* on your telnet screen
      5. Type $$$
      You shold now see CMD on your telnet screen
      6. Perform the commands:
      set wlan phrase
      set wlan ssid
      ***when i did this each letter showed up twice as i typed, but didn’t seem to matter.
      7. When it rebooted, i lost the connection, but since my CoolTerm window was open, i noticed the RN-XV automatically connected to specified SSID and got an ip. My laptop jumped back to my usual wifi network as well
      8. I telnet to that new IP
      9. It should again say *HELLO*, Again type $$$ and again it says CMD.
      10. Now type “ftp u” and the update is performed.

      Now on startup, the RN-XV auto connects to my network and the green light blinks slowly.
      Success! thanks for the guidance, would have taken me much longer without your article.

    • Cardinals Fan 2013 permalink
      February 20, 2012

      to get the money first off want to lick my butthole

    • brazo de oro permalink
      May 16, 2012

      mm you should conect PIO9 to 3.3V that will set the module into Adhoc mode, once this happen, try typing $$$ again. 

    • Terminal_28 permalink
      June 1, 2012

      Ahmad, I’m not too sure about this, but it appears you’re using the Xbee Explorer Regulated. If indeed you are, then please note that there appear to be multiple problems with that particular board regarding level shifting. Apparently, the circuitry on the board interferes with proper operation of the RNXV, so my hunch is that your data is getting to the RNXV garbled.
       Perhaps you could try using the barebones Xbee breakout or some alternate means of connection to see? It could be worth a shot, assuming my blind stab is correct.

  4. Brian permalink
    December 31, 2011

    Are the pins on the WiFly not correct pitch or length for breadboarding? Do I really need the breakout? Thanks, can’t wait to get this and start playing!

    • December 31, 2011

      Correct, the pitch is too small to fit in a breadboard.

    • tom permalink
      August 14, 2012

      They are 2mil spaced, unfortunantly

  5. Philip Tranter permalink
    January 5, 2012

    I started trying to get mine going last night. I got command mode working, and set it up for my wireless network. I could then telnet in from my PC – what I type at one end appears at the other (telnet client or terminal program).

    I have yet to try your GPIO setup.

    I was puzzled by your opening comments, ‘the manual is apparently incorrect and the firmware it shipped with was causing problems’. What version of manuals and Hardware does this relate to (and how did you find all this out)?

    Thanks for an interesting and useful post


    • January 5, 2012

      Thanks! Glad you found the post helpful!

      I discovered the problems with the manual and firmware by emailing with a simultaneously helpful and condescending Roving Networks technical support representative. Hopefully the errors will be reflected in a new official version of the manual and firmware.

  6. Philip Tranter permalink
    January 6, 2012

    Thanks again Tedbot.

    The firmware update (‘ftp u’ command) sorted it all out for me – it upgraded from version 2.28 up to 2.30 There is a ‘gotcha’ waiting for those who would try this – when it upgraded it overwrote and messed up all my stored config settings (even the baud rate became some huge number) – so nothing worked. Took me a while to figure it out, but once I did a factory RESET, it all started working again.

    It is now working as an XBEE replacement in my mobile robot. Trouble is, I’ll now have to rewrite the PC end to use telnet! Advantage is, I only need one RN-XV for a link, instead of 2 XBEEs, and I can now control multiple robots from one PC – synchronised robotics here I come!

    Although I’m now a fan of the RN-XV, it shouldn’t take 3 nights to get them working.


    • ahmad permalink
      January 8, 2012


      Ditto on the 3 nights to get this working.

      I’m planning a similar project controlling multiple devices in my home from a PC. I’m curious about what setup you have in mind. Will you be using the RN-XV as a WebServer or WebClient?

      I’ve had some success with either route, but I’m constantly hitting snags. Would be great to compare notes.


      • January 8, 2012

        I’d say it depends on directionality and network topology. With a robot you’ll likely want full-duplex bidirectionality so it would make sense to use the web client on the RN-XV to establish a continuous TCP session and then just write your own protocol (see my other post for some notes on using Node.js for this, which I highly recommend).

        However, this requires 1) a microcontroller and 2) you to be able to reliably establish the connection to the host, which is easy enough if you’re on your own, controlled LAN, but potentially unreliable in other situations.

        In the situation I wrote this tutorial for, the RN-XV is actually acting as the server, and a web client from other computers dial into it to send the switching commands via the module’s command mode.

        • ahmad permalink
          January 10, 2012

          thanks for the feedback Tedbot, i will look into your suggestions and do some experimentation.

  7. Leonardo-rocha-porto permalink
    February 5, 2012

    Hello. I would appreciate if you could help me. I uploaded a sketch to my arduino to read serial inputs. (Turn a led ON when it receives “H”, and turn it off when receives “L”. How can I send this commands through telnet? (How can I tell my arduino to turn a led ON ? Thank you very much

  8. Chad permalink
    February 9, 2012

    Following this design, everything works sort of. The RN-XV seems to randomly
    hang, noticeable when I telnet in and try to issue commands (to turn on and off
    the LED). The same RN-XV does not hang at all when connected to a Sparkfun Xbee
    USB Explorer. I can telnet in and send many commands with no issues.

    I’m just guessing it’s issues with the power source, as there literally is
    nothing else to this. Any suggestions on how to clean things
    Following this design, everything works sort of. The RN-XV seems to randomly
    hang, noticeable when I telnet in and try to issue commands (to turn on and off
    the LED). The same RN-XV does not hang at all when connected to a Sparkfun Xbee
    USB Explorer. I can telnet in and send many commands with no issues.

    I’m just guessing it’s issues with the power source, as there literally is
    nothing else to this. Any suggestions on how to clean things

    • Ted Hayes permalink
      February 9, 2012

      Argh, yeah, I wish this module was more reliable, and Roving Networks’ tech support doesn’t seem to appreciate the problem.  I have had the same issue where the module, when used in the USB Explorer dongle, works perfectly, but not otherwise.  I haven’t narrowed down the source of the problem yet, so if you discover anything, let us know!

  9. Cardinals Fan 2013 permalink
    February 20, 2012

    fuck all of yall suck my black dong

  10. Rudy Van Nuffelen permalink
    May 7, 2012

    I like your tutorial and got mine working quite quickly, I’m on 2.32 and everything works well.
    I wonder how I can get a webserver to post something to the Wifly module. Say I would like to make  a GPIO change level as an output to switch something, how would you do that on a Wifly ?
    All the examples in the user manual are about posting data when something happens on a io pin. I would really like to do the inverse.
    Thanks for helping out or giving a hint.

    • Andy Beck permalink
      June 9, 2012

      The Roving Network Modules aren’t really designed to act as a server.  I’ve designed a product using an RN-171 and PIC processor that has a simple web server to allow the user to configure the device using a web page it serves up.  However, it takes a fair amount of code to do this, and is quite liomited in its capababikities.
      Andy Beck

  11. Fa_a2z permalink
    June 10, 2012

    Can you please explain further on the mask to turn on other gpio? I tried with 0x21fe in the hopes of turning gpio 1,2 &3 on. however it stays at 0V. oddly Gpio 1 & 8 works fine. Am I missing something?

    • Fa_a2z permalink
      June 11, 2012

      Never mind, found the reason to be related with setting the alternate gpio function. for those encountering the same problem, use set sys iofunct :)

  12. Keklja permalink
    August 18, 2012

    hi. when I try to connect over telnet to RN-XV it says “could not open the connection to the host, on port 23. Connection failed.” I connected my laptop to add hoc and I have ip but when i use telnet over cmd and type “telnet” I get this message. Help please

    • August 18, 2012

      With the telnet program, the host address and port are two separate parameters, so they must be separated by spaces. Try “telnet 2000”

  13. Keklja permalink
    September 6, 2012

    ok i manage to connect over teraterm and I configure module so it can connect on my on network but it doesnt. I mean router can see him, he gets ip address but if i wont to connect I cant. And yes im using new address that my dhcp server gave him

  14. Gethin Evans permalink
    March 8, 2013

    ftp u might not work now since the FTP IP address for Roving Networks has changed. I found this works :-

    set ftp address 0 <—-this is a zero
    set dns name
    ftp update

    Then you MUST do a factory reset, this will not erase your saved config files

    factory RESET

  15. atif satti permalink
    July 3, 2013

    i want to comunicate between two modules can i do that ?if yes then how ???

  16. penguin wifly smasher permalink
    July 16, 2013

    ftp connecting to

    ip address =

    DHCP does not work.
    module does not work

  17. Alex permalink
    August 11, 2013

    I have a question about the wifly module…
    everything is setup and connected to my network,
    well but now i want to send a string (ex.: “abc”) via telnet trough the module to my pic microcontroller (rx/tx pins are connected), how should i setup the wifly to receive the string and forward it to my microcontroller?
    would be nice if someone could give me an advice

  18. SanUSB Laese permalink
    February 1, 2014

    Sketch Arduino for Wifly RN-XV modem configuration without Wifly library and

    with front-end:

Trackbacks and Pingbacks

  1. Getting Physical: Workshop Notes | Limina.Log
  2. XBee Wi-Fi | gr33nonline

Comments are closed.