Ethernet (w5100) sketch hangs

@DCContrarian: My test code didn't work? I did not stop my test yet. It just passed 1200 downloads. How far does it need to go? The memory remaining is still showing 7369.

thank you so much draythomp !!

Ill look into it.

@DCContrarian: My test code didn't work?

I couldn't get your code to work with my web site (but the code is a little foreign to me). As a server, I had the arduino serve up a page 31k+ times without hanging. I'll have to figure out some simple repeating client code to test with apache servers on my lan.

I found that LED blink check (pin 13) is "ethernet death" for an Uno.

Why anyone would blink the LED on pin 13, when pin 13 is used for SPI (which is how the ethernet shield talks to the Arduino) is beyond me. There are other pins that an external LED (with resistor!) can be connected to, for troubleshooting.

@PaulS: How about this reason; I was a little new to Arduino. Blinking pin 13 LED on a Mega2560 is "da bomb!".
Blinking it on a Uno is "ethernet death".
Now I use "Tick" for my public examples.
Live and learn...

Why anyone would blink the LED on pin 13, when pin 13 is used for SPI (which is how the ethernet shield talks to the Arduino) is beyond me. There are other pins that an external LED (with resistor!) can be connected to, for troubleshooting.

On a standard arduino with ethernet shield with an ethernet sketch loaded, the LED on pin 13 is dimly lit as it is apparently being rapidly being turned on/off. I test using a multimeter connected to another pin like pin 4.

zoomkat:

@DCContrarian: My test code didn't work?

I couldn't get your code to work with my web site (but the code is a little foreign to me). As a server, I had the arduino serve up a page 31k+ times without hanging. I'll have to figure out some simple repeating client code to test with apache servers on my lan.

My code is being tested using an Apache server. That code is kinda for me. It will send a GET and load any webpage I want.
This is the function:

byte getPage(byte *ipBuf,char *page)

byte *ipBuf is a 4 byte array containing the ip address
char *page is the character array that contains the document to load.

So this URL
http://1.2.3.4/myfolder/myfile.html
would be downloaded by this code as

byte thisIP[] = { 1,2,3,4 };
getPage(thisIP,"/myfolder/myfile.html");

Just passed 1300 downloads. :slight_smile:

Live and learn...

Especially that part...

OH!! This is not good! At iteration 1365, both devices locked up. No more serial output. No more ethernet requests. :frowning:

OH!! This is not good!

Refer to reply #27.

@PaulS: You are right. Live and learn...

So, do I give up and walk away? I don't think so!
Now I'll try to find what causes that! :slight_smile:

Add: More bad news. Even a soft reset like "Ethernet.begin()" will not fix it.
Hey! Good news!! I know which pins to bend!

And it gets weirder. If I exit the IDE and start it again, the Arduino part starts functioning again, until it tries another GET. Not so by closing and reopening the IDE serial window. That does not restart the Arduino. ??

And it gets worse. The reset button (neither on the Arduino nor the shield) will not reset the ethernet shield. It apparently must be powered down to restart. :frowning:

Now I'll try to find what causes that!

That's what I hoped you'd do.

If I exit the IDE and start it again, the Arduino part starts functioning again, until it tries another GET. Not so by closing and reopening the IDE serial window. That does not restart the Arduino. ??

If you haven't modified the Arduino, closing and opening the Serial Monitor should reset the Arduino.

The reset button (neither on the Arduino nor the shield) will not reset the ethernet shield. It apparently must be powered down to restart.

If I remember correctly, the reset switch on the ethernet shield just brings the Arduino reset button up to the top shield.

Oh, contrar! This is not good. Closing and opening the IDE serial window does not reset anything. Closing and opening the IDE restarts the Arduino ONLY, not the shield. Any communication attempt with the ethernet shield locks up the whole thing. Pressing the reset button will NOT reset the ethernet shield. :frowning:

Edit: After some experimenting, closing and opening the IDE serial window appears to be restarting the Arduino, but not the ethernet shield.

I think it has been reported in the past that a loss of power glitch can cause issues because the ethernet shield will power up prior to the arduino loading its sketch. One way to check is load an ethernet sketch, then momentairly unplug the arduino from the pc usb port then plug back in and see if the ethernet shield restarts. The below has some info. If your pc goes into power save mode or similar that kills power to the usb port, then the ethernet shield restart issues might appear.

Thanks for that info, zoomkat. But I do not want to reset a "broken" ethernet shield. I want it fixed.

I started another test very early this morning. It is downloading every 15 seconds now, and coming up on 800 downloads. If it fails again around 1200-1500 downloads (6 hours), it may be a firmware bug in the shield. If it goes to 5000 or so (20 hours like the last fail), then it might be a thermal problem. That little IC does get a bit warm.

I also have some endless loop prevention in the code in case it is the "client.available()" malfunction again.

Add: These symptoms eliminate the possibility of "pin bending". Even if I separate the reset circuit from the Arduino, the ethernet shield will not reset with that circuit. It appears the only "pin bending" that will work is the power pin.

Update 07:25 CDT
It was not that particular iteration (1365) that caused the failure. It's past that already.

PaulS:
Why anyone would blink the LED on pin 13, when pin 13 is used for SPI (which is how the ethernet shield talks to the Arduino) is beyond me. There are other pins that an external LED (with resistor!) can be connected to, for troubleshooting.

You answered your own question - all other LEDs are external. Blinking the one on the board is easy...

nb. On the Ethernet Arduino they moved the LED to pin 9 so you can blink it all day long.

Does your shield have the SD card built in?

One other bad thing that can happen is that if you don't set the SPI select of the SD card high it can randomly interfere with the Ethernet chip.

Set that pin HIGH in your setup().

fungus:
Does your shield have the SD card built in?

One other bad thing that can happen is that if you don't set the SPI select of the SD card high it can randomly interfere with the Ethernet chip.

Set that pin HIGH in your setup().

Thanks, fungus. I'll try that next test.

Right now it is 9am and my test I started early this morning has not crashed yet.
I just passed the 1760 download mark. It does not seem to be the number of downloads.

BTW, does anyone know where to get a heat sink that small?

You answered your own question - all other LEDs are external. Blinking the one on the board is easy...

Duh! Not if it is already being used by the ethernet setup. :roll_eyes:

Thanks for that info, zoomkat. But I do not want to reset a "broken" ethernet shield. I want it fixed.

You may be basing your conclusions on weak analysis. Do you have control over the server to which you are connecting? Have you reviewed its logs to see if it has had glitches or similar that would have disrupted/delayed one of your connections? 99.999% of the time electrical components work the way they are wired. Most issues arise from some bad or invalid assumption on which programming or operation is based. If you need a break from your testing, try the below code with a browser and see if your shield fails.

// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102:84/ in your brouser
// or http://zoomkat.no-ip.com:84 with dynamic IP service
// use the \ slash to escape the " in the html

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

int x=0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
Server server(84);

void setup()
{
  // start the server
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
     while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // see if HTTP request has ended with blank line
        if (c == '\n') {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          //meta-refresh page every 2 seconds
          x=x+1;
          client.println("<HTML>");
          client.print("<HEAD>");
          client.print("<meta http-equiv=\"refresh\" content=\"2\">");
          client.print("<TITLE />Zoomkat's meta-refresh test</title>");
          client.print("</head>");
          client.println("<BODY>");
          client.print("Zoomkat's meta-refresh test");
          client.println("
");
                    
          client.print("page refresh number ");
          client.println(x);
          client.println("
");
          client.println("
");
          
          client.print("Zoomkat's arduino analog input values:");
          client.println("
");
          client.println("
");
          
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
            }
           break;
          client.println("</BODY>");
          client.println("</HTML>");
         }
        }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}