SOLVED: Ethernet Shield - Mega 2560 - stops communicating, heats

SOLVED

It was the power supply - I replaced the barrel connector 12 volt adapter with a USB charger connected through the USB - B connector and the web server sketch works as expected and the board does not overheat.

Hey all,

Just received a Mega 2560 compatible board and Ethernet shield W5100 and loaded a sketch based on the Ethernet library example “Web Server”. Instead of reporting back analog values, the number of times the web page has been accessed is reported via the variable ‘counter’.

The code is at the end of this post.

The Ethernet Shield was connected directly to my home router.

I first tried powering the Arduino and shield with a 9 volt battery, but noticed that the Power LED would start off dim and quickly fade.

I replaced it with a 12v 0.5 A, 6 W AC adapter. I was able to cycle the web page a number of times, anywhere from 6 to 25 as shown by the counter value in the code, before the web server would stop responding.

I noticed that by the time the web server stopped responding, the microprocessor board would be hot to the touch. If I disconnected power and let the board cool down, I was able to cycle the web page again.

Even when the web server stopped responding, the board would still respond to a ‘ping’ command from the computer that was browsing the web server.

Would I be better off using a different adapter?

Does it seem likely that the Ethernet Shield might be defective?

Thanks!

/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi

 */

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 254, 77);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
int counter = 0;

void setup() {
  // Open serial communications and wait for port to open:
  //Serial.begin(9600);
  //while (!Serial) {
  //  ; // wait for serial port to connect. Needed for native USB port only
  //}


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  //Serial.print("server is at ");
  //Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();

  if (client) {
    //Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        
        char c = client.read();
        //Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          counter++;
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.print("Hello world, counter = ");
          client.println(counter);
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}