Ethernetshield unstable

Hello :slight_smile:

My ethernetshield on an Arduino UNO has lame behaviours. Typically after I failed to upload a sketch, e.g. if i altered some wires and the cable fell out (could be other things). Last time it took me a day to get it back online again, not doing anything else than spamming it with the WebServer example and the WebClient example respectively.

You all know how the normal WebServer sketch shows analog input in the browser like:

analog input 1 is 252
analog input 2 is 278
analog input 3 is 274
analog input 4 is 291
analog input 5 is 0

When it have troubles connecting the same sketch looks a little more like this:

analog input 1 is 252
analog input 2 is 278
analog input 3 is 274
analog input 4 is 291
analog input 5 is 0
R,âc¸YgZ ààÌ%\Ý㞍œb€…ïa0 8),H B€„Ài˜! ˆFB2AJŌѬ°£Î(I$«¦²ÐhËŽMF³Y‘JŒi›³‚ÇÄ ß_¡i+™Î««‹~ÀÀP[9Ÿ™ú+œ’!¦gñÙ#1‰³U<‡¹T û†D©&B"§ËŽ©T‚-SµT*‰¯(‹N®Ú¾…ªˆ@WöOCZ analog input 0 is 561
analog input 1 is 458sh: 5 c‚Sc5=a¢ÚÎý WIZnet0ECEFD7:;ÿ2€¢ÚÎýHTTP/1.1 200 OK Content-Type: text/html Connection: closet0ECEFD7:;ÿ3 €¢ÚÎýHTTP/1.1 200 OK Content-Type: text/html Connection: closeÿ4€¢ÚÎýc‚Sc5=a¢ÚÎý WIZnet0ECEFD7:;ÿ5€¢ÚÎýc‚Sc5=a¢ÚÎý WIZnet0HTTP/1.1 200 OK Content-Type: text/html Connection: close Refresh: 5 analog input 0 is 193

Regarding the client library, it can't connect at all (even not the initialization message "connecting to host"). Sometimes it gives me "Failed to configure Ethernet using DHCP", which is where I would make it connect to the mac and IP that I provided Ethernet.begin(mac, ip) - but nothing happens. Now I'm tired of just waiting and working on nothing, so I would use some time to ask if anybody have had issues alike, and maybe had a solution to the problem? :slight_smile: Else I'll just do the std routine: wait wait wait patience....

Best pakken :slight_smile:

Client code here.
http://playground.arduino.cc/Code/WebClient
Server code here.
http://playground.arduino.cc/Code/WebServerST
Both are very reliable.

I am testing a new, mostly SD file driven server now. It has been working great. If it continues to work good for a while, I'll post it in the playground also.

I'm not sure you read my post at all? :smiley:

Combining both posts, here is what you are saying.

pakken:
Now I'm tired of just waiting and working on nothing, so I would use some time to ask if anybody have had issues alike, and maybe had a solution to the problem?

I'm not sure you read my post at all? :smiley:

I had issues with the standard examples, so I wrote my own. I don't think you understood my response.

Ahh okay :slight_smile: But the examples are fine for me, when it works. But it doesn't even want to connect. Now I've been going steadily for 7 hours :slight_smile: Only happens when disconnecting or something goes wrong in uploading. It's like i knock it over for a period of time, and then suddenly it slowly wake up :smiley:

But the examples are fine for me, when it works.

The phrase "when it works" is the key. Without the timeout stuff in my sketches, they will freeze (lock up). Maybe not right now, maybe not for an hour. Maybe not for a day or two. But they do freeze up just like your subject says. Unstable.

Maybe I should try with gateway and subnet. What timeout stuff do you mean?

pakken:
Maybe I should try with gateway and subnet. What timeout stuff do you mean?

My client sketches are here.
http://playground.arduino.cc/Code/WebClient
Here is the read response with the timeout code from that page.

  // connectLoop controls the hardware fail timeout
  int connectLoop = 0;

  while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      Serial.write(inChar);
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet
    if(connectLoop > 10000)
    {
      // then close the connection from this end.
      Serial.println();
      Serial.println(F("Timeout"));
      client.stop();
    }
    // this is a delay for the connectLoop timing
    delay(1);
  }

  Serial.println();

  Serial.println(F("disconnecting."));
  // close client end
  client.stop();

I tried with your sketch:

Starting ethernet...
10.48.10.113
Ready
connecting...failed
Fail 1
connecting...failed
Fail 2
connecting...

Now I changed to a MEGA and I have to go through this again... geez :smiley:

I run mine days at a time without a fail. I haven't had a sketch freeze (lockup) in quite a while, maybe months. I'm testing my new server code now. Here is the info with ip address if you want to try it.
http://forum.arduino.cc/index.php?topic=197103.0

You can DoS it by requesting the pages with the pictures too often, but it recovers. At least it has so far.