WiFly Shield Library : Stuck on join() function

Hi everybody,

Please allow me to paste the topic I posted on Arduino.cc. As the maker of the library is one of the member of Sparkfun, I might have more succes over there:

I’m currently having an odd problem. I succeeded in doing what I was trying for some weeks, this means being able to transmit data via Wifi and making the Arduino react according to these data. So I can use my Android Phone to activate a motor, for instance. I used for that the WiFly Shield library and everything workED fine. Indeed, I just came back to my house and decided to keep working on my project, so I was planning to use the WiFi Network of my house… However, I got a hard problem over there… Here’s my program :

#include "WiFly.h"
#include "Servo.h"


char passphrase[] = "a269c7a7297a99669ee443af29";
char ssid[] = "Alice-dbde";

Server server(80);
Servo myservo;

void setup() {
  
  Serial.begin(9600);
  Serial.println("Setting up");
  WiFly.begin();
  Serial.println("WiFly started");
  
  
if (!WiFly.join(ssid, passphrase)) {
    while (1) {
      
      Serial.print("Error");
    }
  }

 Serial.println("Can u reach me ?");
  Serial.print("IP: ");
  Serial.println(WiFly.ip());
  myservo.attach(5);
  server.begin();
}

void loop() {
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        
        Serial.print(c);
        
        if (c == 'a')
        {
          motor();
        }
        
        if (c == 'b')
        {
          unmotor();
        }
        
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(100);
    client.stop();
  }
}

void motor()
{
  
  for(int pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}

void unmotor()
{
  
  for(int pos = 180; pos > 0; pos -= 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}

This worked absolutely fine at my school, but not there.

Indeed, it gets stuck here:

if (!WiFly.join(ssid, passphrase)) 

By stuck, I mean that the programm doesn’t go after the if statement. But still does the Wifly.join or it wouldn’t be able to join the network (it doesn’t enter the while loop).

Moreover, I can see with the LEDS my Arduino is connected to my network ! I can even do a telnet on it (as I know its IP thanks to my DHCP configuration). So to sum up, it’s stuck over there, but I does work. The problem is that as my program can’t go after the WiFly.join(), I can’t do anything else… I tried to connect manually, it perfectly work, but I’m bound to use this Library for this project (my teacher told me…). Would anyone have an idea about that odd problem ? O.o

I tried that :

boolean b = WiFly.join(ssid,passphrase)
Serial.print(b);

And nothing got returned. The join function just doesn’t want to work here at home…

PS : I can connect manually (so with the SpiUart Terminal ) and via the Autoconnect program provided by Sparkfun. But not with the library ON THIS network…

Hi, i guess your netwerk is using WEP encrytion. If that is the case you should change WiFly.join(ssid, passphrase) to ```
WiFly.join(ssid, passphrase, WEP_MODE)

Did you find a solution to this problem?

I’m experiencing the same issue now. I can’t get text to print in the terminal past “WiFly Shield Terminal Routine.” The green LED is fast blinking indicating that no IP address is found.

My project’s application is similar to yours. I would like to send a signal from my iPhone to the Wifly to control some hardware. I created an app on my iPhone that can write a 1 or a 0 to a text file on my server. When a one is inputted into the text file I would like my server to contact the Wifly board.

Did you use the webclient sketch to connect to your server? What code must be uploaded to the server so that it is “listening” for incoming connections?

Any help would be great!

Thanks,

Andrew