Pages: [1]   Go Down
Author Topic: Arduino Wifi official shield unstable connection  (Read 1469 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there!

I'm currently trying to implement a Wifi-controlled robot, using the official Arduino wifi shield bound to an Arduino UNO R3. A computer is supposed to send a one char instruction to be executed by the Arduino under the form of orders sent to 2 servos. The pure wifi part of the connection works like a charm.

Unfortunately, it seems, as several topics on this forum suggest it, that the ability to connect is rather random. I can get this to work once or twice between two initialization sequence, with the Arduino acting either as a client or as a server but whatever the configuration, all this stops working after a few seconds. It looks like the wifi shield stops responding as if it was hung forever until the next reset.

I tried maintaining a continuous TCP connection and opening/closing the connection whenever needed (every second) but neither seem to work reliably. After a few seconds, the packets seem to be lost (as a Wireshark analysis shows). No ACK coming from the Arduino.

1. Did someone get something working reliably using some similar configuration (two servos on pins 5 and 6)?
2. Would there be some usable alternative for such use case? If so what would you, guys, advise? Another wifi module? Another class of wireless device (bluetooth, zigbee...)?

Many thanks in advance for your guidance. May you have any further questions, feel free to ask. I can post the code I use on the computer side if this helps.

Benoît

Below, an excerpt of my code :
Code:
const int srv1 = 5;
const int srv2 = 6;
const int SERVO_ZERO = 94;
Servo servo1;
Servo servo2;

void setup()
{
  // initialize serial:
  Serial.begin(9600);

  servo1.attach(srv1);
  servo1.write(SERVO_ZERO);
  servo2.attach(srv2);
  servo2.write(SERVO_ZERO);
 
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }
  // you're connected now, so print out the status:
  printWifiStatus();
}

void loop() {
  Serial.println("connecting...");
  if (client.connect(server, port)) {
    Serial.println("connected");
  }
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed disconnecting");
    client.stop();
  }

  while (client.available()) {
    char c = client.read(); // Read only one char
    processChar(c);// Mostly sending orders to the servos, nothing rocket-science here
    client.flush();
    Serial.println("disconnecting");
  }

  delay(1000);
}
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 484
Posts: 18764
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Shouldn't you do a client.stop() once you are done with the connection?

Also, how is all this powered? The servos may be introducing electrical noise.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I added a client.stop() at several places but got not much success... The connection seems fairly unstable anyway.

Regarding the power supply, all comes from the USB port through the 5v power pin of the Arduino.

I tried to use another independent power supply but got nothing more than the previous result.

This is kind of frustrating. I'm beginning to think I should have chosen another Wifi shield.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear all,

I have got exactly the same problem. I am controlling DC motors via the official Wifi shield. Systematically after a while the connection hangs up and both the shield and the arduino become frozen.

It would be very helpful to find a solution for this problem.

Thanks in advance

Marco
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i think so, I tried to use another independent power supply but got nothing more than the previous result. thank you
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

just to let you know I got some stable examples running using this example https://github.com/arduino/wifishield/blob/hd_2.7/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino

I still don't know why it is reliably working anyway. I also must admit I don't drive any motor with it now.

Of course this may constrain the architecture of the solution you're planning to build.

I keep you posted on this.

Best regards,

Benoît
Logged

New Brunswick, Canada
Offline Offline
Newbie
*
Karma: 1
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am also having same connection issues. Works great one minute then switch to different wifi device and everything freezes up.  Using stand-alone linksys wifi router (not connected to internet) laptop and samsung phone for testing. Using a 2 relay control setup. Code works fine and connection to router seems stable but freeze-up issues all the time. Same as others, restarts and resets ( in no particular order) sometimes gets it working again...  smiley-confuse
Logged

Pages: [1]   Go Up
Jump to: