Troubleshooting the WiFly shield for Arduino

For the discussion of Arduino related topics.

Moderator: phalanx

Troubleshooting the WiFly shield for Arduino

Postby follower » Thu Dec 09, 2010 10:59 am

In order to help with troubleshooting when people are having problems with the WiFly shield I've created a tool which enables you to enter command mode and send commands manually.

This tool requires the WiFly Shield code library alpha 1 release is installed.

The tool provides some instructions on how to use the tool when run.

The steps you should follow are:

  • Upload SpiUartTerminal.pde sketch.
  • Remove power from Arduino and WiFly shield then plug it back in (this ensures the WiFly module is in a semi-known state).
  • Open Serial Monitor in Arduino IDE.
  • Read the instructions that appear.
  • You should get the message "Connected to SPI UART.". If you do not get this message then this tool will not be able to help you--you will need to confirm the library is configured properly for the version of the WiFly board you use and try again.
  • Ensure the line ending pop-up menu at the bottom of the Serial Monitor window is set to "No line ending".
  • Type "$$$" without quotes and then press the "Send" button
  • The display should respond with "CMD". If it doesn't, make sure you had removed & reapplied power before starting. If it still doesn't work, try changing the line ending to "Carriage return" and press the send button--if this works continue the remainder of the steps. Otherwise this tool will not be able to help you.
  • Change the line ending to "Carriage return" and press the send button.
  • The display should respond with something like "<2.19>" which tells you the version of the firmware on the module.
  • Try sending commands like "scan" or "get everything" (without quotes).

If you get this far then it means the shield and module are somewhat functional which means the problem is probably related to connecting to the network you're trying to reach.

--Philip;

Update: Fixed link.
Last edited by follower on Wed Dec 15, 2010 8:46 pm, edited 1 time in total.
follower
 
Posts: 280
Joined: Sun Mar 14, 2010 11:58 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby LMas » Wed Dec 15, 2010 5:58 pm

Hi SpiUartTerminal.pde link not working.
LMas
 
Posts: 33
Joined: Sun May 09, 2010 6:22 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby follower » Wed Dec 15, 2010 8:47 pm

Thanks for pointing that out. Moved the location of the file within the repository and didn't think of it breaking the link. :)

Should be correct again now.

--Philip;
follower
 
Posts: 280
Joined: Sun Mar 14, 2010 11:58 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby LMas » Thu Dec 16, 2010 7:50 am

thanks i found it :)
LMas
 
Posts: 33
Joined: Sun May 09, 2010 6:22 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby zaktux » Sun Jan 16, 2011 2:20 pm

i have configure my linksys router (WRT54G2) whit "mixed band" (g+b) and doesn't work. Only work fine over B mode.

the error was:
2.21> Disconn from myssid, AUTH-ERR

solved changing the confing to B mode only.


(sorry for my english)
zaktux
 
Posts: 2
Joined: Sun Jan 16, 2011 2:15 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby follower » Mon Jan 17, 2011 1:05 am

zaktux wrote:i have configure my linksys router (WRT54G2) whit "mixed band" (g+b) and doesn't work. Only work fine over B mode.
Sorry, I'm not sure what would be causing that issue. Maybe you could check if the router has error logs that give you more information?

--Philip;
follower
 
Posts: 280
Joined: Sun Mar 14, 2010 11:58 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby amirahmed123 » Sun Mar 06, 2011 12:39 pm

Hi all.
I am using a Wifly shield from sparkfun and adruino UNO.
i m able to get into command mode. but not able to connect to wifi network.
is there some specific setting to be done for creating wifi network. confused over WEP/WPA. Which one to choose?
i use a netgear WG602 access point
amirahmed123
 
Posts: 4
Joined: Sat Mar 05, 2011 4:48 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby amirahmed123 » Mon Mar 07, 2011 3:24 pm

hi, til now i was not able to connnect to available wify network with my wifly shield.
i tried to connect mannually from command mode
and it associated.
but i m not able to connect by my sketch
is there some problem with the library?
amirahmed123
 
Posts: 4
Joined: Sat Mar 05, 2011 4:48 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby Gary_BSEE » Wed Apr 06, 2011 6:05 pm

So after about 7 hours of troubleshooting I've configured my Wifly via Arduino UNO on a static IP etc to send data over TCP connection. Here is my code, I hope it helps some peoples' problems!

Code: Select all
/*
  Timer
 
  This program takes analog input from a soleniod monitoring
  module on pin 9 (max 5V, 40mA), and records and transmits
  its "on" duration.
 
  Used in conjunction with a PC running a monitoring program,
  on the same Wi-Fi network with preconfigured settings, this
  program allows the Arduino UNO to communicate these timed
  durations with the PC, for further calculation and storage.
 
  This program is Intellectual Property of GSMAC.
  Created 26 Jan 2011
  Modified 5 Apr 2011
  -- Added functionality for WiFly GSX Module to send data
     over Wi-Fi network
     
  By Gary Willette
 
   
 The circuit:
 * Soleniod monitoring module attached to digital input 9
 * Pin 9 connected to ground via a 10kOhm resistor (pulldown)
 * Sparkfun WiFly shield attached to UNO
 */
 
// include the WiFly code to communicate with SpiSerial:
#include "WiFly.h"

//SET THESE PARAMETERS FOR WI-FI NETWORK
const char WEP_KEY [] = "enter_key_here";
const char AUTH_LEVEL [] = "1"; // 0=OPEN 1=WEP 2=WPA1 3=Mixed WPA1&WPA2-PSK 4=WPA2-PSK 6=AD HOC
const char SSID [] = "enter_SSID_here";
const char DHCP [] = "0"; //0=static (DHCP disabled) 1=DHCP enabled
const char WIFLY_IP [] = "192.168.1.208";
const char BACKUP_IP [] = "192.168.1.209";
const char WIFLY_PORT [] = "2000";
const char PC_IP [] = "192.168.1.7";
const char PC_PORT [] = "2000";
const char GATEWAY_IP [] = "192.168.1.1";
const char NETMASK [] = "255.255.255.0";
const char DNS_SERVER [] = "192.168.1.1";
const char ANTENNA_OPTION [] = "0";  //0=internal, 1=external
const char UART_MODE [] = "2"; //2=make TCP connection when there is data to send
const char LINKMON [] = "5"; //number of AP re-scans until reassociation

//define constants to be used
const int dataSendInterval = 10000; // interval of time to send data (5 seconds)
const int Delay = 100; //interval to wait between wi-fi parameter sets
const int buttonPin = 6;       // select the input pin for the button output
const int ledPin = 5;

//data variables
unsigned long currentFillTime = 0;
unsigned long afterFill = 0;
unsigned long beforeFill = 0;
unsigned long lastDataSend = 0;
unsigned long totalFillTime = 0;
unsigned long oldFillTime1 = 0;
unsigned long oldFillTime2 = 0;
int transmissionNumber = 0;

// Variables will change:
int ledState = LOW;          // the current state of the output pin
int buttonState = LOW;       // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
int buttonPush = 0;          // will prevent writing vars while button is held
long lastDebounceTime = 0;   // the last time the output pin was toggled
int debounceDelay = 40;      // the debounce time; increase if the output flickers

//displays on terminal everything in SPI Serial buffer
void readFromWifly(){
  delay(100);
  while(SpiSerial.available() > 0) {
    Serial.print(SpiSerial.read(), BYTE);
  }
  Serial.print("\n");
  delay(100);
}

void setup() {
  pinMode(buttonPin, INPUT);  // declare the sensor pin as input
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  Serial.begin(9600);
  Serial.println("Attempting to connect to SPI UART");
  SpiSerial.begin();
  Serial.println("Connected to SPI UART");
 
  // Exit command mode if we haven't already
  SpiSerial.println(""); 
  SpiSerial.println("exit");
  readFromWifly();
  // Enter command mode
  SpiSerial.print("$$$");
  delay(100);

  // Reboot to get device into known state
  Serial.println("Rebooting");
  SpiSerial.println("reboot");
  readFromWifly();
  delay(3000);
 
  // Enter command mode
  Serial.println("\nEntering command mode.");
  SpiSerial.print("$$$");
  readFromWifly();
  delay(500);

  // Set authorization level to <auth_level>
  SpiSerial.print("set w a ");
  SpiSerial.println(AUTH_LEVEL);
  Serial.print("Set wlan to authorization level ");
  Serial.println(AUTH_LEVEL);
  readFromWifly();
  delay(500);
 
  //disable DHCP
  SpiSerial.print("set ip dhcp ");
  SpiSerial.println(DHCP);
  Serial.print("Set WiFly DHCP to: ");
  Serial.println(DHCP); 
  readFromWifly();
  delay(500);
 
  //set WiFly IP Address
  SpiSerial.print("set ip address ");
  SpiSerial.println(WIFLY_IP);
  Serial.print("Set WiFly IP to: ");
  Serial.println(WIFLY_IP); 
  readFromWifly();
  delay(500);
 
  //set Backup WiFly IP Address 
  SpiSerial.print("set ip backup ");
  SpiSerial.println(BACKUP_IP);
  Serial.print("Set Backup IP to: ");
  Serial.println(BACKUP_IP); 
  readFromWifly();
  delay(500);
 
  //set WiFly remote port
  SpiSerial.print("set ip local_port ");
  SpiSerial.println(WIFLY_PORT);
  Serial.print("Set Wifly local port to: ");
  Serial.println(WIFLY_PORT); 
  readFromWifly();
  delay(500);
 
  //set PC IP Address
  SpiSerial.print("set ip host ");
  SpiSerial.println(PC_IP);
  Serial.print("Set PC IP to: ");
  Serial.println(PC_IP); 
  readFromWifly();
  delay(500);
 
  //Set PC remote port
  SpiSerial.print("set ip remote_port ");
  SpiSerial.println(PC_PORT);
  Serial.print("Set PC remote port to: ");
  Serial.println(PC_PORT); 
  readFromWifly();
  delay(500);
 
  //set Gateway IP Address
  SpiSerial.print("set ip gateway ");
  SpiSerial.println(GATEWAY_IP);
  Serial.print("Set gateway IP to: ");
  Serial.println(GATEWAY_IP); 
  readFromWifly();
  delay(500);

  //set Netmask Address
  SpiSerial.print("set ip netmask ");
  SpiSerial.println(NETMASK);
  Serial.print("Set netmask to: ");
  Serial.println(NETMASK); 
  readFromWifly();
  delay(500);
 
  //Set DNS Address
  SpiSerial.print("set dns address ");
  SpiSerial.println(DNS_SERVER);
  Serial.print("Set dns addresss to: ");
  Serial.println(DNS_SERVER); 
  readFromWifly();
  delay(500);

  // Set passphrase to <auth_phrase>
  SpiSerial.print("set wlan key ");
  SpiSerial.println(WEP_KEY);
  Serial.print("Set security phrase to ");
  Serial.println(WEP_KEY);
  readFromWifly();
  delay(500);
 
  //set antenna to internal or external
  SpiSerial.print("set wlan ext_antenna ");
  SpiSerial.println(ANTENNA_OPTION);
  Serial.print("Set wlan ext_antenna: ");
  Serial.println(ANTENNA_OPTION); 
  readFromWifly();
  delay(500);
 
  //setup to make tcp connection when data from uart is received
  //and close connection after data is sent
  SpiSerial.print("set uart mode ");
  SpiSerial.println(UART_MODE);
  Serial.print("Set UART mode: ");
  Serial.println(UART_MODE); 
  readFromWifly();
  delay(500);
   
  //set access point link monitor (if AP goes down, scan x # of times before
  //re-associating)
  SpiSerial.print("set wlan linkmon ");
  SpiSerial.println(LINKMON);
  Serial.print("set Access point rescans to ");
  Serial.println(LINKMON);
  readFromWifly();
 
  // Join wifi network <ssid>
  SpiSerial.flush();
  Serial.print("Joining '");
  Serial.print(SSID);
  Serial.println("'");
  SpiSerial.print("join ");
  SpiSerial.println(SSID);
  delay(5000);
  readFromWifly();
 
  //ping PC IP Address (to check for connection
  SpiSerial.print("ping ");
  SpiSerial.println(PC_IP);
  Serial.print("\nping ");
  Serial.println(PC_IP);
  readFromWifly();
  delay(2000);
 
  //save config
  SpiSerial.println("save");

  //show network details
  SpiSerial.println("show net");
  readFromWifly();
  SpiSerial.println("get uart");
  readFromWifly();
  SpiSerial.println("exit");
}

void loop()

  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
 
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
    buttonState = reading;
   
    if(buttonState==HIGH){
      if(buttonPush!=1){
        beforeFill=millis();
        //Serial.println(beforeFill);
        buttonPush=1;
        digitalWrite(ledPin, HIGH);
      }
    }
    else if(buttonState==LOW){
      if(buttonPush!=0){
        afterFill=millis();
        //Serial.println(afterFill);
        currentFillTime=afterFill-beforeFill;
        totalFillTime+=currentFillTime;
        buttonPush=0;
        digitalWrite(ledPin,LOW);
      }
    }
  }

  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState = reading; 
  if (millis() - lastDataSend >= dataSendInterval)
  {   
     Serial.println(totalFillTime);
     SpiSerial.println(totalFillTime); //send fill time to Wi-Fi
     transmissionNumber++;
   
     // store recent fill time into old time and once more
     // old into extra old, for redundancy and backup
     oldFillTime2 = oldFillTime1;
     oldFillTime1 = totalFillTime;
     totalFillTime = 0;
     lastDataSend = millis();
  }
}


Please note that to use this over WPA, you'll need to change the command from "set wlan key " to "set wlan phrase ". If using over OPEN (unprotected) network, just set AUTH_LEVEL to "0".

Take care,

Gary
Gary_BSEE
 
Posts: 6
Joined: Wed Apr 06, 2011 5:59 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby roadfun » Sun May 01, 2011 12:49 pm

Gary

Thanks for posting your code. I extracted the code to write the SPI and used it to debug a problem I was having. Saved me some serious time...
roadfun
 
Posts: 17
Joined: Sat Apr 30, 2011 1:30 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby cbernett » Mon Jun 13, 2011 9:12 am

hello!

i've gotten the WIFLY up and running at home with my airport express (WPA2), but am needing to transfer my whole setup to work, where I also have a secure WPA/WPA2 network, but am having trouble connecting to it. I'm using the library designed for it and it just hangs. so i thought i'd try your troubleshooting sketch, but am not able to get into command mode at all. in fact, following is what i see, with no response from the IDE when i enter $$$:

--------------------------------------

This is a tool to help you troubleshoot problems with the WiFly shield.
For consistent results unplug & replug power to your Arduino and WiFly shield.
(Ensure the serial monitor is not open when you remove power.)

Attempting to connect to SPI UART...
Connected to SPI UART.

* Use $$$ (with no line ending) to enter WiFly command mode. ("CMD")
* Then send each command followed by a carriage return.

Waiting for input.

WG÷·—77÷·Ø@'÷7o¶Þw·˜@774Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@774Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@77¶Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@774Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@774Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@77¶Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@77¶Á緟`±·ßG·±yç¶6¶¡@g¶ ‘Ƕ¡ˆ×0ÁWG÷·—77÷·Ø@'÷7o¶Þw·˜@774Á緟`

This goes on for as long as I let it run. Any ideas?

Thank you so much!
c
cbernett
 
Posts: 21
Joined: Mon May 30, 2011 4:21 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby cbernett » Mon Jun 13, 2011 3:40 pm

Hello!

I'm having a tricky problem with the WiFly Library. The WiFly are connecting beautifully at home (airport express, WPA2) but not at my studio (WPA mixed). It doesn't error out or associate, it just sits on the begin() call. I tested it out with the SpiUartTerminal sketch, and it looked good. I got this:

<2.21> set wlan ssid Method
AOK
<2.21> set wlan phrase xxxxxxxx
AOK
<2.21> set wlan auth 4
AOK
<2.21> scan
<2.21>
SCAN:Found 7
Num SSID Ch RSSI Sec MAC Address Suites
1 SmartFi 01 -67 WPAv1 74:91:1a:0f:7e:a9 AESM-TKIP 3104 0
2 MuseGames 02 -69 WPA_Mix 00:24:01:6f:8a:bd AES/TKIPM-TKIP 3104 0
3 shadygoliath1 06 -73 WEP 00:26:62:0d:1a:f6 1104 2
4 M3 Entertainment 09 -69 WPA_Mix 0c:d5:02:1e:42:b5 TKIPM-TKIP 1104 6
5 Method 11 -55 WPA_Mix 00:26:b0:fe:8b:a3 AES/TKIPM-TKIP 3100 0
6 DHAwifi 11 -62 WPAv1 00:21:29:ae:62:8e TKIPM-TKIP 1104 0
7 DHAguest 11 -74 WEP 00:15:e9:1e:d2:f8 3104 0
join # 5

DeAuth
Auto-Assoc Method chan=11 mode=MIXED SCAN OK
Joining Method now..
<2.21> Associated!
DHCP: Start

Method's ssid is showing up at WPA mixed - so it seems like all should be good. Any thoughts? I'm super stuck and really want to get this working at this location. Thanks so much in advance!

Claudia
cbernett
 
Posts: 21
Joined: Mon May 30, 2011 4:21 pm

Re: Troubleshooting the WiFly shield for Arduino

Postby k_san88 » Tue Jul 19, 2011 4:18 am

Gary_BSEE wrote:So after about 7 hours of troubleshooting I've configured my Wifly via Arduino UNO on a static IP etc to send data over TCP connection. Here is my code, I hope it helps some peoples' problems!


Gary, thank you very much! Your code is a great rosetta stone for me. Most appreciated.
k_san88
 
Posts: 9
Joined: Tue Jul 19, 2011 3:14 am

Re: Troubleshooting the WiFly shield for Arduino

Postby jasel » Mon Sep 05, 2011 12:34 am

I'm a little confused about the relationship between Arduino and the WiFly shield. I'm developing an application to monitor my boat and most importantly the level of water, in case the automatic pumps stop working for some reason. It works as expected, but if I telnet into the WiFly the sketch stops running. If I reboot the WiFly, only the shield reboots, not the Arduino Uno. Do I really have to connect some kind of relay to the WiFly itself to be able to power cycle the whole thing and get the Arduino Uno to reboot and rerun the sketch?
jasel
 
Posts: 2
Joined: Sun Aug 28, 2011 10:58 am

Re: Troubleshooting the WiFly shield for Arduino

Postby asifnadeem » Thu Nov 10, 2011 8:09 am

Cbernet!
I am having the same problem, instead of all that what u r getting, i am getting only one symbol which jus keeps on repeating while the tx on my arduino never stops blinking. can anybody help?
asifnadeem
 
Posts: 2
Joined: Thu Nov 10, 2011 4:45 am

Next

Return to Arduino

Who is online

Users browsing this forum: No registered users and 1 guest