Electronic – Arduino + Ethernet Shield hangs after some time


I am using an arduino to retrieve some data from a web application. The problem is that after some time it starts to hang.

For testing I used the default EthernetClient sketch and modified it a bit that every few secounds there is send a request to the server to get the information. For testing I don't do anything with the data I get so it does only send the request and retrieve the data.

For testing I use a Arduino Mega 2560 + Ethernet Shield and a Arduino Ethernet board, I experience the problem on both. It runs from 30 minutes up to one day then the whole board freezes. The boards doesn't get hot or anything else.

At first it seams to work but after some undefined time it starts to hang, does anyone have an idea what could cause this? Is there a bug on the arduino or the W5100 Ethernet chip?

Would you try to fix this issue or switch to a Raspberry Pi? Using the watchdog timer is no option because it doen't work on the Mega without changing the bootloader.

UPDATE (Added my loop code, there are no memory issues, I testet that before):

void loop()
  if (client.available()) {
    char c = client.read();

  if (!client.connected()) {


    if (client.connect(server, 80)) {
      client.println("GET / HTTP/1.0");

This is all it does, in the setup there is the default initialization code from the Ethernet demo sketch.


Testing with Arduino Mega + WiFi Shield hangs too.

Testing with EtherMega 2560 from freetronics is now running 2 days without any problems I will continue this for min. one week. My only problem with this bord is the price. It's around 100$.

Best Answer


Here is a working solution testet with Mega (1.0.1) and Due (1.5.3)

Ok, it seams there is a bug in the arduino 1.0.x libraries that causes the ethernet module to hang after some time, when you have to permanetly query a server.

With the Arduino Due (arduino 1.5.2) it is now running and also much faster! So its maby the best option to use this when you have to deal with much network traffic and many operations. I will contact the arduino developers about this issue and update this answer when I got more information about this problems.