Skip to content

Getting started with the RN-XV WiFi Module & Node.js

2011 December 7

The RN-XV WiFi module is a nifty little WiFi module designed to fit the same pinout as an XBee, so it’s intended to be a drop-in replacement.

Tonight I whipped up a little test of the module to get a joystick to talk to a Node.js server over WiFi.  I attached +3V power and ground to the module (pins 1 and 10, respectively), pin 2 (TX) to Arduino digital pin 0 (RX), and pin 1 (RX) to Arduino digital pin 1 (TX).  That’s all the hardware setup you need.

I used this WiFly library to handle the connection.  All it does is talk to the WiFly module over serial and send control commands, so the library abstracts that a bit.  Here’s the Arduino sketch I built:

And here’s the very basic Node.js server that just prints out the values it receives:

Related Posts:


24 Responses
  1. Eric Viele permalink
    December 28, 2011

    I’m curious what Arduino you are using? I am using an Uno which is a 5 volt Arduino and my understanding is that any 3.3 volt module will not be able to talk over the serial connection because it’s actually a 0-5 volt on/off communication and the 5 volts is too much for the RN-XV and as such it will require some form of level shifting.

    So I’m guessing you are using a 3 volt Arduino but if not I’m wondering how you got the two devices to talk.

    Would love to hear back from you.

    Oh and great projects!

    • December 29, 2011

      I’m using an Arduino Diecimila. The RN-XV module is powered by the Arduino’s 3.3v output. No level-shifting required.

      • January 23, 2012

        I can understand Eric’s confusion, The data-sheet for the RN-XV says the UART_TX & UART_RX are only 3.3V tolerant.

        http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wireless/WiFi/WiFly-RN-XV-DS.pdf

        • January 23, 2012

          Oh hm, interesting.  Well, I don’t appear to have damaged the device with my current setup… I’ll have to look more into this.  Thanks!

          • August 1, 2012

            Hi TedBot, have you found more about this? How to handle 5V/3.3V TX/RX stuff properly? Cheers!

          • KratosAurion permalink
            August 4, 2012

            Yeah, I’d also like to know, I have my doubts about the stability of running a 3.3V chip at 5v. Just wanted to know. Thanks

  2. Thomas Pujolle permalink
    January 8, 2012

    Hello there!

    I have an arduino Uno, and I didn’t managed to get this working properly :(
    I just cannot join any network, and at the best I get some “$$$” logged out.

    Anyone ?

  3. January 31, 2012

    Seems WiFly.setUart(&Serial); does not work anymore.

    Getting error: ‘class WiFlyDevice’ has no member named ‘setUart’

    • Ted Hayes permalink
      January 31, 2012

      Hm, that’s strange, it’s right here: https://github.com/jcrouchley/WiFly-Shield/blob/master/src/WiFly/WiFlyDevice.cpp#L210

      • January 31, 2012

        Thank you, my bad – used original SFE lib instead of the forked. However now Client is renamed in the lib to WiFlyClient:
        WiFlyClient client(serverAddress, serverPort);

  4. Kaarel Hanson permalink
    March 4, 2012

    Hi!

    I’m using Arduino Mega ADK together with Arduino Wireless SD Shield and RN-XV module but cannot get this code working. I also use TinkerKit Mega Shield for Led lights, idea is basically the same: set led on when wireless network is accessed or if failed. After a bit of debugging I found that processing stops or hangs in WiFly.begin(); endlessly. Could this be because I use a shield instead of directly connecting the module to Arduino? 

    • March 4, 2012

      Hm, well the shield is just patching tx and rx, so it’s probably not interfering.  Have you tried it yet with just the module itself? Also, the WiFly library may have changed; it could have something to do with setUart…

  5. Pon permalink
    March 22, 2012

    Hi T3dbot!

    How do you connect RN-XV to Arduino Uno? Does it matches the pins directly or should I use some kind of breakout board?

    Thanks in advance!

    • Ted Hayes permalink
      March 22, 2012

      You can wire it as described here—just power, ground, rx and tx.

  6. hxorn00b permalink
    July 14, 2012

    I am running the node.js server on Mac OSX Lion in the terminal and the “server bound” shows up OK. However, I am not seeing the joystick results being streamed to this terminal window. The data is showing up in the Arduino serial window OK. What could I be doing wrong here?

  7. gabriellalevine permalink
    July 28, 2012

    Hey – the tutorials are super helfpul thanks!

    I’m trying to hook it up exactly like you have it, but Im not getting past WiFly.begin() loop. I’ve tried various baud rates and I’ve made sure that my credentials work when I connect directly to the wifly rn xv using coolTerm – I’m wondering if you have an idea? Since I’m new to these I dont know what I might start to think about to debug past what I’ve already tried-

  8. atif satti permalink
    July 3, 2013

    hey all cann i comunicate between two wifly modules ??

  9. lcr permalink
    July 25, 2013

    HELLO there; I would like to do the same thing to read the phone jack on a phone and send the contents to a node.js socket waiting for the read…
    any ideas?

  10. SanUSB Laese permalink
    February 1, 2014

    Sketch Arduino WiFi for Wifly modem configuration without library and
    with front-end: https://dl.dropboxusercontent.com/u/101922388/WiflySanUSB.zip

  11. Thorsten permalink
    October 20, 2014

    Hi,
    I am trying to get to work my WIFLY with OSC messages. So I found
    in combination with
    However, already facing a problem with compiling the basic sketch, that returns me:

    Build options changed, rebuilding all
    In file included from SimpleReceive.ino:13:
    C:\Program Files (x86)\Arduino\libraries\WiFlyHQ/WiFlyHQ.h:78: error: conflicting declaration ‘typedef const char prog_char’
    c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/avr/pgmspace.h:212: error: ‘prog_char’ has a previous declaration as ‘typedef char prog_char’
    SimpleReceive.ino: In function ‘void setup()’:
    SimpleReceive:29: error: ‘class WiFly’ has no member named ‘setupForUDP’
    SimpleReceive:29: error: expected primary-expression before ‘>’ token
    SimpleReceive:42: error: ‘class WiFly’ has no member named ‘printStatusInfo’

    Can you help me out here? Since it seems to be a WIFLYHQ Problem I just try to contact you first.

    Thx
    Thorsten

Trackbacks and Pingbacks

  1. Getting Physical: Workshop Notes | Limina.Log
  2. RN-XV WiFly | niltoid.
  3. XBee Wi-Fi | gr33nonline

Comments are closed.