W5100 Ethernet Shield problem - solution ?

Dear All,

Like many of you, I had problems with my Wiznet W5100 ethernet shield - random hangs and not responding to http requests ( usually after 2 - 4 days ) I'm running two servers 24/7 - each in differrent location, router and ISP. Both of them randomly hang - I could ping them but no web page was displayed and only hard reset make them respond again. On one of them I have server and client - client is sending data to Xivelly - when hang occurs, client it not responding aswell.
So I was looking for solution to this but with no luck. I found this great thread : Ethernet (w5100) sketch hangs - Networking, Protocols, and Devices - Arduino Forum and I modified one of my Arduinos like suggested ( pin 4 high, modded library file ), downloaded ICMP library to ping my router every 60 seconds and in case of failure, make ethernet.begin procedure , AND I set uptimerobot.com account to ping a port every 5 min on both of my ethernet shields ( I'm using dyndns.org to access my servers from Internet ) and guess what.... both servers are runnig 6 days without hanging ! Even the one I didn't modified !
Could any one try and confirm this ? Is it possible that pinging a port solved this problem or is it just coincidence ? There is many more free services like uptimerobot so you can try anything else ..

PS - I'm using standard ethernet library, verry simple web pages with ajax to update 10 values and NO SD cards .

Hello,

I also have hangup problems with my w5100 (and arduino Uno)
I Use it as a client to send "midi over tcp" to a digital mixer (Alen & Heath QU 16)
Everything works finie when i send informations, but sometimes the mixer sends some bytes to the arduino -> if there's a few bytes, it's ok, but when there's too much at the same time, arduino freezes.

Do you think that your solution may help me?

Thank you!

some pictures of my project: Dropbox - File Deleted - Simplify your life

I don't think this solution will help in this case but you could try a solution posted in a thread pointed in my first post - you'll have to modify library file just a little. Otherwise start a new thread and post you complete code - maybe there is something wrong with it :slight_smile:

My solution is for servers running for a long time - before that my servers would hang after 3 to 4 days. Now they are running 8 days without problem. I'd like some to confirm this..

If the connection fails or the server stalls, the client code will lock up unless you have a timeout in your client code. Here is my client code with the timeout. Look through the code for the loopCount variable.
http://playground.arduino.cc/Code/WebClient

If you have a SD card in the shield's slot, remove it.

thank you for ideas! I'll try and tell you.

waski:
Otherwise start a new thread and post you complete code - maybe there is something wrong with it :slight_smile:

-> here's it : control an Alen&Heath QU-16 digital mixer by MIDI over TCP - Networking, Protocols, and Devices - Arduino Forum

Both servers runnig 10 days without any trouble...

SurferTim (or anyone else),

Is it possible to check if the Arduino Shield is hung by making an explicit call ? I cannot use a delay in my code, so I am thinking of a Timer that wakes up every 10 minutes. But what function should the Timer check to see if the the Shield has not hung ? I am using the WebClient Repeating code and the Arduino (shield) hangs.

thx,

Netnut

Did you read my first post in this topic? This is how you check if your shield is running. Since I posted this topic I got 0 ( ZERO) hangs! Use a simple timer, ping your router every minute and if ping didn't succeed - initialize shield again .

@netnut: Are you using my code from the link above? If so, where does it hang? What is the last message displayed on the serial monitor?

@waski, I did read the first post and also the long string in the 2011 Forum (very interesting), but is there is faster way to check that the shield is working than pinging the router ? I am accepting interrupts and don't want to be in timer code for a while.
BTW, I am now exclusively using the Arduino Ethernet board and not the shield as the Board has a lower failure rate and costs $45 with a lower profile.

@SurferTim, I will deploy your code from the playground tonight and let you know. Right now I am using the WebClient Repeating code.

/*
  Repeating Web client
 
 This sketch connects to a a web server and makes a request
 using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
 the Adafruit Ethernet shield, either one will work, as long as it's got
 a Wiznet Ethernet module on board.
 
 This example uses DNS, by assigning the Ethernet client with a MAC address,
 IP address, and DNS address.
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 19 Apr 2012
 by Tom Igoe
 
 http://arduino.cc/en/Tutorial/WebClientRepeating
 This code is in the public domain.
 
 */

#include <SPI.h>
#include <Ethernet.h>

#define DEBUG1 1

// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x0D, 0xCE, 0xD2};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(192,168,0,220);

// fill in your Domain Name Server address here:
//IPAddress myDns(1,1,1,1);

// initialize the library instance:
EthernetClient client;

char server[] = "www.arduino.cc";

unsigned long lastConnectionTime = 0;          // last time you connected to the server, in milliseconds
unsigned long trips = 0;                       // number of loops in the code
boolean lastConnected = false;                 // state of the connection last time through the main loop
const unsigned long postingInterval = 2*1000;  // delay between updates, in milliseconds

void setup() {
  // start serial port:
  Serial.begin(115200);
  // give the ethernet module time to boot up:
  delay(1000);
  // start the Ethernet connection using a fixed IP address and DNS server:
  //Ethernet.begin(mac, ip, myDns);
   // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    if (DEBUG1) Serial.println("Failed to configure Ethernet using DHCP");
    // DHCP failed, so use a fixed IP address:
    Ethernet.begin(mac, ip);
  }

  // print the Ethernet board/shield's IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  if (client.available()) {
    char c = client.read();
    //Serial.print(c);
  }

  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected() && lastConnected) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
  }

  // if you're not connected, and ten seconds have passed since
  // your last connection, then connect again and send data:
  if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
    if (DEBUG1) Serial.print("trips ");
    if (DEBUG1) Serial.println(trips);
    httpRequest();
    trips = 0;
  }
  // store the state of the connection for next time through
  // the loop:
  lastConnected = client.connected();
  trips++;
}

// this method makes a HTTP connection to the server:
void httpRequest() {
  // if there's a successful connection:
  if (client.connect(server, 80)) {
    Serial.println("connecting...");
    // send the HTTP PUT request:
    client.println("GET /latest.txt HTTP/1.1");
    client.println("Host: www.arduino.cc");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();

    // note the time that the connection was made:
    lastConnectionTime = millis();
    if (DEBUG1) Serial.println(lastConnectionTime);
    
  } 
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
    Serial.println("disconnecting.");
    client.stop();
  }
}

and I get the following output
My IP address: 10.128.0.154
trips 0
connecting...
5673

disconnecting.
trips 126865
connecting...
8051

disconnecting.
trips 127517
connecting...
10428

disconnecting.
trips 127059
connecting...
8467613

disconnecting.

And then nothing.

thx,

netnut

Use mine from the playground and let me know how it did for you.