Download Print this page

Advertisement

Quick Links

 
 
Wifi Shield V2.0
This WiFi shield features the RN171 TCP/IP module to allow your Arduino/Seeeduino to
connect with up to 802.11b/g wireless networks.
The shield's default communication protocol with the Arduino is UART/Serial, and you
may select which digital pins (D0 to D7) to use for RX and TX with two jumper rows
we've incorporated. The shield also has two on-board Grove connectors for I2C and
Serial to allow the shield to be used with any of our Grove devices.
An on-board antenna allows the shield to cover a wider range and transmit stronger
signals. The RN171 module supports TCP, UDP, FTP, and HTTP communication
protocols to meet the needs of most wireless and Internet of Things (IoT) network
projects e.g. smart home networks, robots control, personal weather stations.
The shield is very well documented with our examples below and its
user
manual.

Advertisement

loading
Need help?

Need help?

Do you have a question about the Wifi Shield V1.0 and is the answer not in the manual?

Questions and answers

Summary of Contents for Seeed Wifi Shield V1.0

  • Page 1     Wifi Shield V2.0 This WiFi shield features the RN171 TCP/IP module to allow your Arduino/Seeeduino to connect with up to 802.11b/g wireless networks. The shield's default communication protocol with the Arduino is UART/Serial, and you may select which digital pins (D0 to D7) to use for RX and TX with two jumper rows we've incorporated.
  • Page 2: Specifications

    Version Tracker Parameter  Wifi Shield V1.0  Wifi Shield V1.1(v1.2)  Wifi Shield V2.0  Voltage  +3.5V~+5V  +3.5V~+5V  +3.5V~+5V  Standard Shield  Yes  Yes  Yes  Communication Mode  Serial port  Serial port  Serial port  Standard Shield  No  Yes  Yes  Antenna Type  mast antenna  PCB antenna  onboard antenna  Library File  Wifi Shield Library V1.0 New Wifi Shield Library New Wifi Shield Library the same as v1.2      Specifications Parameter  Value  Operating voltage  3.3~5.5 V  Compatible board directly  Arduino Uno/Seeeduino  Current  25~400mA  Transmit power ...
  • Page 3: Hardware Overview

    Please note that "Not recommended" means that it might have chance to work with the platform board however requires extra work such as jump wires or rewriting the code. If you are interested in digging more, welcome to contact with techsupport@seeed.cc. Click to see full...
  • Page 4 1. Serial Peripheral Interface (SPI) Connections (MOSI, SCK, MISO): These pins are not connected to any of the Arduino's pins, they are independent and the logic level output/input of them is 3.3V. They can be used to communicate with the Arduino via SPI but a 3.3V logic converter between these pins and the Arduino's will be needed.
  • Page 5 RN171 WiFi Module The RN-171 is a standalone complete TCP/IP wireless networking module. Due to its small form factor and extremely low power consumption, the RN-171 is perfect for mobile wireless applications. It incorporates a 2.4GHz radio, 32-bit SPARC processor, TCP/IP stack, real-time clock, crypto accelerator, power management, and analog sensor interfaces.
  • Page 6 Label Description  Status  Hardware Connection  Solid ON: indicates that it is associated and  Internet access is OK  D1  Red LED. Indicates the  Solid ON: connected over TCP.  Connected to GPIO4 of the  TCP/IP connection status.    RN171 module  Fast Toggle (2 times/second): No IP address or module is in command mode. Slow Toggle (once/second): IP address is RST  Red LED. WiFi module reset  Solid ON: The reset button (WIFI_RST) is been  Connected to Reset of the  status.  pressed.  RN171 module.  PWR  Green LED. Indicates WiFi  Solid ON:The module/shield is powered up. ...
  • Page 7  Parameters:   ssid: The name of the access point you want the shield to connect to   phrase: The password/phrase of the access point you want the shield to connect to   auth: The authentication type of the access point you want the shield to connect to. Can be  one of the following constants:   WIFLY_AUTH_OPEN   WIFLY_AUTH_WEP   WIFLY_AUTH_WPA1   WIFLY_AUTH_WPA1_2   WIFLY_AUTH_WPA2_PSK   WIFLY_AUTH_ADHOC   Returns:   boolean: true if the connection to the access point was successful, false otherwise.   Example:    #include <SoftwareSerial.h> #include "WiFly.h" SoftwareSerial uart(2, 3); // create a serial connection to the WiFi shield TX and RX pins. WiFly wifly(&uart);...
  • Page 8 As for the code, you need to do some change as well: 1SoftwareSerial uart(10, 3); // create a serial connection to the WiFi shield TX and RX pins. receive()  Description:   Can be used to read data from the shield, an alternative for the Arduino's read() function.   Syntax:   receive(uint8_t *buf, int len, int timeout)   Parameters:   buf: A buffer array where the bytes read from the shield is stored. ...
  • Page 9 See File->Examples->WiFi_Shield->wifly_test sketch for a complete example. sendCommand()  Description:   Some our functions (e.g. join(), reboot(), save()) act as wrappers for the text commands listed  in the user manual of the RN171 module. The function sendCommand() allows you to come up  with your own wrapper function if ours do not meet your needs.   Syntax:   sendCommand(const char *cmd, const char *ack, int timeout)   Parameters:   cmd: Any command from the RN‐171's user manual.   ack: The expected return string from the command   timeout: The time allowed before considering the output a bad request/response   Returns:  boolean: true if the WiFi shield responded with the ack string, false otherwise.   Example: // our join() function is wrapper for the join command, as seen below. //The string "Associated"...
  • Page 10 Position the jumpers in the WiFi shield such that digital pin 2 (D2) is selected for WIFI_TX, and digital pin 3 (D3) is selected for WIFI_RX as shown in the photo below. These are the pins we will use to send and receive information from the RN-171. Pins D2 for TX, and D3 for RX Step 2: Software/Code In the sketch below we have created a UART object to allow us to send and receive data from...
  • Page 11 while (wifly.available()) // if there is data available from the shield Serial.write(wifly.read()); // display the data in the Serial monitor window. while (Serial.available()) // if we typed a command wifly.write(Serial.read()); // send the command to the WiFi shield. Step 3: Entering Command Mode The WiFly RN-171 module in the WiFi shield can operate in two modes: data, and command.
  • Page 12 Example 2: Connect to An Access Point / Internet Router In this example we will show you how to connect the WiFi shield to an access point (your internet router) with and without you typing the commands required: Connecting By Typing Commands This section will teach you how to connect the WiFi shield to an access point using commands from the RN-171 datasheet, by going through this section you will then know exactly what is happening in the background when you use our WiFi Arduino libraries.
  • Page 13 A description of the commands you entered in the steps above is available in the table below. A more detailed description of each command can be found in the RN171's user manual. Number Commands  Description  1  scan  This command performs an active probe scan of access points on all 13 channels. When  you use this command, the module returns the MAC address, signal strength, SSID name,  and security mode of the access points it finds.  2  set wlan auth 4  Find the value that corresponds to the security protocol on your access point. Then, tell  the WiFly what security protocol to use, it is the number shown in Figure 1 that  corresponds to the access point's security protocol. Here we choose “4”.  3  set wlan phrase  Tell the WiFi shield your passphrase.  seeed‐mkt ...
  • Page 14 Change the code to use your own SSID (access point name), and KEY (your access point's password), then upload the sketch to your Arduino IDE. #define SSID " SEEED-MKT " #define KEY " seeed-mkt " With the sketch uploaded to your Arduino board, open the serial monitor window. If the shield was successful in joining the access point an "OK"...
  • Page 15 Configuring The Shield to Connect On Power‐Up The shield can be configured to connect on power up, you only have to do this once: 1. Send the "set wlan ssid mySSID" command replacing mySSID with your SSID  2. Send the "set wlan join 1" command.  3. Send the "save" command.  Now the shield will connect to the access point automatically on power up. A description of what each command does can be found in the RN-171 datasheet and in the table below.
  • Page 16 5. Get the IP address of your shield with the command "get ip". The IP address and port will be  displayed to the right of "IP=" in the response (e.g. IP=192.168.0.10:80)  6. Open your web browser and type your shield's IP address in your web browser's URL bar and press  Enter to visit it.  7. Your Arduino's serial monitor window will display an HTTP response similar to the one below. This  is the information that your browser sent to the shield to request data.  *OPEN*GET HTTP/1.1 Host: 192.168.0.10 Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 The browser is now waiting for data, the Wifi module can send sensor values, serve web pages, or any other data straight back to the browser! In this case, the browser is waiting for a web page.
  • Page 17 SoftwareSerial wiflyUart(2, 3); // create a WiFi shield serial object WiFly wifly(&wiflyUart); // pass the wifi siheld serial object to the WiFly class void setup() wiflyUart.begin(9600); // start wifi shield uart port Serial.begin(9600); // start the arduino serial port Serial.println("--------- WIFLY Webserver --------");...
  • Page 18 delay(1000); // delay enough time for the browser to complete sending its HTTP request string // send HTTP header wiflyUart.println("HTTP/1.1 200 OK"); wiflyUart.println("Content-Type: text/html; charset=UTF-8"); wiflyUart.println("Content-Length: 244"); // length of HTML code wiflyUart.println("Connection: close"); wiflyUart.println(); // send webpage's HTML code wiflyUart.print("<html>");...
  • Page 19 Step Three: Visiting the webpage Now visit that IP address in your web browser. The webpage below should be displayed, it contains a link to Yahoo! and Google and a button that doesn't do anything (yet): A simple webpage with two links and one button served from the WiFi shield. When the webpage is visited the serial monitor window will also display a "New Browser Request!"...
  • Page 20 Note In case of some browsers, like Google Chrome, even typing the URL in the bar sends a webpage request,  this is because these browsers try to get the webpage's title for the user's convenience even before  he/she visits the webpage.  Example 5: Controlling The Arduino Digital Pins From a Webpage (Toggling LEDs From an Webpage) In this example we will create a webpage with three buttons to control three different digital pins in the Arduino. For this tutorial follow the steps below. We have also created a video where we explain the code in more detail.
  • Page 21 Step 2: Arduino Sketch Upload the following code to your Arduino board but replace "mySSID" and "myPassword" with your access point's SSID name and password: #include <SoftwareSerial.h> #include "WiFly.h" #define SSID "mySSID" #define KEY "myPassword" // check your access point's security mode, mine was WPA20-PSK // if yours is different you'll need to change the AUTH constant, see the file WiFly.h for avalable security codes #define AUTH...
  • Page 22 wifly.sendCommand("set comm open *OPEN*\r"); // set the string that the wifi shield will output when a connection is opened delay(100); Serial.println("Join " SSID ); (wifly.join(SSID, KEY, AUTH)) { Serial.println("OK"); else Serial.println("Failed"); delay(5000); wifly.sendCommand("get ip\r"); wiflyUart.setTimeout(500); if(!wiflyUart.find("IP=")) Serial.println("can not get ip"); while(1);;...
  • Page 23 Serial.println("LED Control"); // the user wants to toggle the LEDs pinNumber = (wiflyUart.read()-48); // get first number i.e. if the pin 13 then the 1st number is 1 secondNumber = (wiflyUart.read()-48); if(secondNumber>=0 && secondNumber<=9) pinNumber*=10; pinNumber +=secondNumber; // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number digitalWrite(pinNumber, !digitalRead(pinNumber));...
  • Page 24 wiflyUart.print("<button id=\"11\" class=\"led\">Toggle Pin 11</button> "); // button for pin 11 wiflyUart.print("<button id=\"12\" class=\"led\">Toggle Pin 12</button> "); // button for pin 12 wiflyUart.print("<button id=\"13\" class=\"led\">Toggle Pin 13</button> "); // button for pin 13 wiflyUart.print("<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script>"); wiflyUart.print("<script type=\"text/javascript\">"); wiflyUart.print("$(document).ready(function(){"); wiflyUart.print("$(\".led\").click(function(){"); wiflyUart.print("var p = $(this).attr('id');");...
  • Page 25 Step 4: Visit The Webpage Visit the IP address in a web browser. A webpage with three buttons, like the one below, should display. Click on the buttons to control the LEDs. LED control webpage served from the WiFi shield. The Arduino will also respond back to the web browser with the pin's state, the browser will display this in an alert window.
  • Page 26 Arduino serial comm output when an HTTP request is sent to the shield. Example 6: WiFi Shield and Android App The Android app you can use to control the Arduino's pins through the WiFi or Ethernet Shield.
  • Page 27 Android Application We've created an Android app that can toggle the digital pins in the Arduino through the WiFi shield, to see how the app works and learn about the code watch the video in this link: Video - WiFi Shield Android App for Arduino Pin Control Software Download the Android Studio project/source form this link:...
  • Page 28 http://api.openweathermap.org/data/2.5/weather?q=San%20Francisco,US Step 2: The Arduino Code Section 13 of the WiFly manual teaches you different ways to connect to a web server, but in all cases we need to specify the name of the server (or IP address if the server does not have a domain name), and then the data we wish to send.
  • Page 29 delay(5000); wifly.sendCommand("set ip proto 18\r"); //enable html client delay(100); wifly.sendCommand("set dns name api.openweathermap.org\r"); // name of the webserver we want to connect to delay(100); wifly.sendCommand("set ip address 0\r"); // so WiFly will use DNS delay(100); wifly.sendCommand("set ip remote 80\r"); /// standard webserver port delay(100);...
  • Page 30 JSON weather string shown in the Arduino serial monitor window. Example 8: TCP Communication With Terminal In this example we'll show you how to send information from the WiFi shield to a PC terminal program. We'll make a simple Arduino console with menus that will give you the option to see the Arduino digital pin's state and toggle them.
  • Page 31 #include <SoftwareSerial.h> #include "WiFly.h" #define SSID "mySSID" #define KEY "myPassword" // check your access point's security mode, mine was WPA20-PSK // if yours is different you'll need to change the AUTH constant, see the file WiFly.h for avalable security codes #define AUTH WIFLY_AUTH_WPA2_PSK #define FLAG_MAIN_MENU 1...
  • Page 32 wifly.sendCommand("set comm open *\r"); // set the string or character that the wifi shield will output when a connection is opened "*" delay(100); wifly.sendCommand("set ip protocol 2\r"); // set TCP protocol delay(100); Serial.println("Join " SSID ); (wifly.join(SSID, KEY, AUTH)) { Serial.println("OK");...
  • Page 33 pinNumber = val-48; // get first number i.e. if the pin 13 then the 1st number is 1 secondNumber = (wiflyUart.read()-48); if(secondNumber>=0 && secondNumber<=9) pinNumber*=10; pinNumber +=secondNumber; // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number // Create the "You want to toggle pin x?? OK..."...
  • Page 34 pinState+=getPinState(13); pinState+="\r\n"; wiflyUart.print(pinState); // prints the option to enter a pin number void printSubMenu2() wiflyUart.print("\r\nEnter the pin number you wish to toggle: "); // get a pin state as a string. String getPinState(int pinNumber) if(digitalRead(pinNumber)) // check if the pin is ON or OFF return "ON";...
  • Page 35 In the image above the IP Address and Port would be the following: 192.168.0.10:80 Step 4: Configure The TCP Terminal and Connect to The Shield Open RealTerm and in the "Display" tab enter "30" for "Rows" and select the "Scrollback" option: RealTerm window: rows = 30, and Scrollback option checked.
  • Page 36 In the "Send" tab select one of the options from the menu either "1" or "2", enter it in the text box and press "Send ASCII" to send the value. For example, to toggle pin 13 enter "2" and press "Send ASCII", then when prompted "Enter the pin number you wish you toggle"...
  • Page 37: Tech Support

    PC's list of WiFi networks available. To learn more about adhoc mode check out the WiFly RN User Manual section 16 "Adhoc Networking Mode" Tech Support Please submit any technical issue into our forum or drop mail to techsupport@seeed.cc. http://wiki.seeedstudio.com/Wifi_Shield_V2.0/ /12-6-18  ...