1 Introduction Getting Started with the RN-XV WiFly October, 2018 Revision 3 This guide will introduce you to using the RN-XV (or RN-171-XV) WiFly wireless LAN module with the Arduino UNO via the Wireless Proto Shield. 1.1 What s Covered This guide will teach you the following: Some general information concerning the hardware involved How to connect the WiFly to the Arduino How to configure the WiFly using only the Arduino s USB to serial interface How to establish a connection between the WiFly and a WLAN access point 1.2 What You ll Need A computer with Arduino IDE installed A USB A to Mini-B cable Arduino UNO Arduino Wireless Proto Shield RN-XV WiFly module WiFi router 2 Hardware Overview 2.1 RN-XV WiFly The WiFly is a Microchip Technology, Inc. (formerly Roving Networks) RN-171 module mounted on a break-out board. Three status LEDs are provided to relay information to user. See Table 2 for a summary of their functions. 1
Table 1: WiFly Status LED Summary Condition Red LED (D3) Yellow LED (D2) Green LED (D1) On solid Connected over TCP Fast Blink Not associated Data Transfer No IP address Slow Blink Associated, no Internet IP address OK Off Associated, Internet OK * Table duplicated from [1] 2.2 Wireless Proto Shield The hardware connection between the WiFly and Arduino is accomplished using the Wireless Proto Shield. This Shield has two rows of headers for the WiFly to plug into, a Serial Select Switch, a Reset button and some status LEDs. 2.2.1 Serial Select Switch The Serial Select Switch connects the WiFly on the Wireless Proto Shield to either one of two devices on the Arudino board: the microcontroller or the USB-to-Serial chip. The USB position allows the WiFly to connect directly to a computer using the USB-to-Serial chip so that it may be configured. The MICRO position connects it to the Arduino s ATmega328P microcontroller for normal operation. Please note that the switch has to be in the USB position to program the Arduino while the Wireless Proto Shield is attached. Figure 1: The Serial Select Switch Table 2: Serial Select Switch Function Summary Position Connection Usage USB WiFly < > USB-to-Serial chip Configuring WiFly using a computer MICRO WiFly < > Arduino microcontroller Normal operation The Arduino cannot be programmed with the switch in this position October, 2018 2 UG-WFLY Rev. 3
3 Using the WiFly 3.1 Preparing the Hardware 1. Connect Wireless Proto Shield, Arduino and WiFly together. 2. Using a jumper, short the Reset and GND positions on the WiFly Proto Shield s header as shown in Figure 2. This will hold the Arduino in reset while the WiFly is being configured. 3. Move the Serial Select Switch to USB position. 4. Connect the Arduino to the computer. Figure 2: Shorting Reset to GND 3.2 Configuring the WiFly 3.2.1 Entering Command Mode The WiFly has two modes: Data mode and Command mode. Data mode is the normal operating mode of the WiFly and it will output status messages over its serial interface while in this mode. Command mode is used to configure the WiFly. To enter Command do the following: 1. Open the Arduino IDE and bring up the Serial Monitor from the Tools menu 2. Ensure that No Line Ending and 9600 baud are selected 3. Type $$$ in the input field and hit Send; the WiFly will respond with CMD as in Figure 3. Additionally, its green status LED will begin blinking rapidly to indicate that it is in Command mode. 4. The WiFly will only accept commands if they are followed by Carriage Return, so change that setting now. In general, the WiFly will return AOK for most commands, and ERR for invalid commands October, 2018 3 UG-WFLY Rev. 3
Figure 3: Successfully Entering Command Mode 3.2.2 Factory Reset If the WiFly s configuration is in an unknown state, it s a good idea to perform a Factory Reset and name the device before going any further. 1. Enter Command mode 2. Send factory RESET 3. Send reboot to restart the device and save the default settings 4. Re-enter command mode 5. Send set opt deviceid <string> where <string> is the name your WiFly will have on the network 6. Send save 7. Send reboot 3.2.3 Connecting to an Access Point Connecting to an access point is accomplished by doing the following: 1. Enter Command mode 2. Send set wlan ssid <string> where <string> is the name of the access point you wish to connect to 3. Send set wlan join 1 so that the WiFly connects automatically after rebooting 4. Send save 5. Send reboot to restart the device to connect to access point October, 2018 4 UG-WFLY Rev. 3
3.2.4 Verifying the Connection Now that the WiFly is connected to an access point, use get ip a to verify that the WiFly has been assigned an IP address by the router. Table 3: Some Useful Commands Command Description get mac returns the WiFly s MAC address (can be obtained anytime, no WLAN connection necessary) get ip returns the IP address and the port the WiFly is listening on, along with other settings get ip a returns the IP address only get wlan display information about the current WLAN connection set ip localport 1025 change the port the WiFly listens on to 1025 (default is 2000) join connect to the access point saved in the WiFly s configuration leave disconnect from the access point See [2] For a complete description of the WiFly s commands 3.3 Communicating with the WiFly via TCP over WiFi For this part of the guide, you ll need to connect your computer to the same WiFi access point as the WiFly. In Windows 1, open a command prompt and begin a telnet session by typing telnet and hitting the enter key. The prompt will change to say Mircrosoft Telnet. Now, do the following: 1. Issue o <ip address> 2000 (<ip address> will have the form 192.168.X.X) to connect to the WiFly 2. Once connected, type some characters into the prompt; they should show up in Arduino IDE s serial monitor 3. Send some characters through the serial monitor as well, they ll show up in the telnet session 3.4 Communicating with the WiFly via the Mercury Competition Router This time, the WiFly will connect to the competition router and your computer will connect to the internet via another access point; that is they will be on separate networks. 1. Get your WiFly s MAC address using get mac 2. Change the port it listens on using set ip localport <port>, where <port> is a four digit number 3. Give the MAC and port number to the person running the router, they will tell you the public IP and port to connect to 4. Once your WiFly is whitelisted on the router, it will connect 5. Telnet into the WiFly using the public IP and port you ve been assigned 1 Telnet has to be enabled in Window 10 October, 2018 5 UG-WFLY Rev. 3
References [1] Roving Networks, RN-171-XV 802.11 b/g Wireless LAN Module, Datasheet, version 1.04, Oct. 29, 2012. [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/rn- 171- xv- dsv1.04r.pdf. [2] Microchip Technology, Inc., WiFly Command Reference Manual, Manual, version B, Sep. 2015. [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/50002230b.pdf. October, 2018 6 UG-WFLY Rev. 3