Ethernet shield crashes router??

This is a strange problem... When I hook up my Arduino with Ethernetshield (w5100) to my home network through an ethernet switch, it works. I've been using it for over a year to control lights over the internet. It is however very slow in responding, so I wanted to evaluate my code. The ethernet switch is upstairs, so to avoid having to work in a broom closet I took the Arduino to the living room and plugged it in directly into my cablemodem. When I powered on the Arduino through the USB bus on my computer, I noticed in the serial monitor there was no connection to either the time server or my web server. Strange, because it worked fine, albeit a bit slow, when it was upstairs. Then my wife complained her internet connection was dead. So I checked mine and indeed, the wifi on my computer was dead also. I checked a computer connected via wire to the router and this was also no longer connected to the network. I rebooted the router (a UPC-Cisco EPC3925) waited for everything to be normal again and plugged in the Arduino. Gone was my internet. I tried the client code from the Ethernet examples and this appeared to work fine. But when I uploaded the webserver sketch it crashed the router again. When the switch is between my router and the Arduino the problem goes away... I can post my code, but the problem occurs also with the standard Ethernet/WebServer example from the Arduino application. Any thoughts?

I'm sorry, but I've read your post a few times and I am confused..

"The ethernet switch is upstairs, so to avoid having to work in a broom closet I took the Arduino to the living room and plugged it in directly into my cablemodem."

--- does this mean your unplugging your router from the cablemodem and plugging the arduino into the cablemodem?? If so, this will probably not work.. possibly if your code uses dhcp AND you shut down and restart the cable model.. However this will kill the network/internet connection in the rest of the house..

Also, do you mean an actual network switch? or the router? or the cable modem?

You also state "When the switch is between my router and the Arduino the problem goes away..." this makes me thing you actually have a switch, if you do, it has to be between the router and the arduino.. If you put it in front of the router then it will fail to do what your expecting..

What is your network layout?? It should be cable modem>> Router >> Switch(if needed) >> Computers/arduino's..

Mmmm… I thought my explanation was clear, but apparently not as clear as I hoped.
My setup is cablemodem/router/->switch->EthernetShield.
But the cablemodem/router (from now on called modem) has four ethernet ports on it so it is also possible to connect ethernet devices directly to it. So everything downstairs that requires a cable (mediacenter, gameconsole, TV) is connected to the modem, stuff upstairs is connected to the switch which is in turn connected to the modem. This setup works fine. What I did when everything went black was disconnect the Arduino from the switch and plug it into the modem. This seems to work fine as long as I only run client software on the Arduino, a server sketch crashes the modem. I checked the modem log, which is set to report everything, but it does not mention this. There are no ip- or mac- conflicts.

By the way, as I did not mention this before, I do not use DHCP on the Arduino but a fixed address.

Have you tried changing the mac address? Try this mac address.

byte mac[] = { 
  0x00, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

Yes, tried deadbeeffeed, feeddeadbeef and some less readable combinations, no change. Makes sense, because if it was a MAC conflict the problem would also occur when only client code is loaded in the Arduino. But as far as my experiments go, it only happens with server code.

I'm also experiencing this issue with my Ethernet shield. Every time I connect or upload a new sketch, my WiFi disconnects and I have to reset the router. Were you ever able to find a solution?

@tpatch: Are you using dhcp to get an IP, or are you using a static IP assignment?

If you do not post your code, it is almost impossible to help troubleshoot this.

edit: Also post the make and model of the router. That could help too.

@SurferTim, here is the code I’m currently working with (I removed my API key for the site I’m using, but everything else is the same).

I’m using a static IP for the Arduino. I was attempting to use DHCP before, but thought that might be the issue.

When I upload a new sketch, the network drops off for all devices, and I have to reset the router. After that, I can sometimes make a successful request on the Arduino.

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

byte mac[] = { 0x16, 0x9E, 0x1E, 0xCB, 0x72, 0x45 };
byte ip[] = { 192,168,0,111 };
byte gateway[] = { 192,168,0,1 };
byte subnet[] = { 255,255,255,0 };
byte server[] = { 24,220,112,46 };

// initialize the library instance:
EthernetClient client;

char serverName[] = "api.openweathermap.org";

const int requestInterval = 20000;  // delay between requests
long lastAttemptTime = 0;   // last time you connected to the server, in milliseconds

String json = "";   // string to hold the text from server
String weather = "";    // string to hold JSON object


void setup() {
  
  // reserve space for the strings:
  json.reserve(256);

  Serial.begin(9600);
  
  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  
  Serial.println("Connecting...");
  
  // attempt a DHCP connection:
  if (!Ethernet.begin(mac)) {
    Serial.println("First Connection Failed, trying with IP and Gateway");
    // if DHCP fails, start with a hard-coded address:
    
      analogWrite(redPin, 255);
      analogWrite(bluePin, 0);
      analogWrite(greenPin, 0);
    
      Ethernet.begin(mac,ip,gateway);
      
      Serial.println(Ethernet.localIP());
      Serial.println("Connecting...");
      
      if (client.connect(serverName,80)) {
        Serial.println("Connected");
        // Make a HTTP request:
      }
      else {
        Serial.println("Connection failed");
      }
  } else {
    Serial.println("Connected!");  
  };
  
  // connect to server:
  connectToServer();
}



void loop(){
  if (client.connected()) {
    if (client.available()) {
      // read incoming bytes:
      char inChar = client.read();
      
      json += inChar;
      
      if (inChar == '\n') {
        Serial.println(json);
        if ( json.startsWith("{") ) {
          weather = json;
          Serial.print("JSON: ");
          Serial.println(weather);
        };
        json = "";
      } 
      
  } else if (millis() - lastAttemptTime > requestInterval) {
    Serial.println("Server disconnected; reconnecting");
    connectToServer();
  } else {
    Serial.println("Waiting to retry");
  };
};



void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("Connecting to server...");
  if (client.connect(serverName, 80)) {
    Serial.println("Making HTTP request...");

    client.println("GET /data/2.5/weather?id=5231851&APPID=MYAPPID HTTP/1.1");
    client.println("HOST: api.openweathermap.org");
    client.println();
  };

  lastAttemptTime = millis();
};

Try this simple code. Does it crash the router?

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

byte mac[] = { 0x16, 0x9E, 0x1E, 0xCB, 0x72, 0x45 };


void setup() {
 
 Serial.begin(9600);
 
 // disable SD card if one in the slot
 pinMode(4,OUTPUT);
 digitalWrite(4,HIGH);

 
 Serial.println("Starting ethernet dhcp...");
 
 // attempt a DHCP connection:
 if (!Ethernet.begin(mac)) {
   Serial.println("Failed");
 } else {
     Serial.println(Ethernet.localIP());
 }
}

void loop(){
}

Thanks for your help on this. I tried that code and the router crashed again. I modified it to the code below, bypassing the DHCP attempt and specifying the IP and gateway, and that seems to be working without causing any network issues. Any ideas why trying to assign an IP to the Ethernet shield would cause everything to go down?

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

byte mac[] = { 0x16, 0x9E, 0x1E, 0xCB, 0x72, 0x45 };
byte ip[] = { 192,168,0,111 };
byte gateway[] = { 192,168,0,1 };
byte subnet[] = { 255,255,255,0 };

void setup() {
 
 Serial.begin(9600);
 
 // disable SD card if one in the slot
 pinMode(4,OUTPUT);
 digitalWrite(4,HIGH);

 
 Serial.println("Connecting...");
 Ethernet.begin(mac,ip,gateway);
 Serial.println(Ethernet.localIP());
  
}

void loop(){
}

Can you be more specific about "the router"? Like make and model? Otherwise I can't help you.

Sorry, it’s a Cisco DPC3825. Also, I saved the network traffic from one of the crashes, screenshot is attached.

If the router crashes when the Arduino requests network settings, I don’t know if you will be able to use the ethernet shield on that router. You can try it with a static IP, but use an IP of somewhere between 192.168.0.2 and 192.168.0.9. The dhcp server owns all IPs above those. Cisco routers are a bit funny about that.

You might also try a different mac address.

So, I’ve been working on this issue off and on, and I think I finally found the problem and wanted to share in case anyone else comes across this.

I wasn’t aware that pins 10, 11, 12, and 13 on the Uno were used for the Ethernet shield, and I had been using 10 and 11 for status LEDs. Once I stopped using those pins, my connection to the internet became much more consistent with no network crashes.

Your code showed no use of D10 and D11.

This is a lesson in "If you think it is not important enough to mention, it probably is".

This exactly is happening to me! Very strange.
With the arduino and ENC28J60 plugged into Macbook Pro, no issues, but as soon as I plug the ethernet cable into the ECN28J60, WAN drops out for all devices connected to the router. (gf’s laptop, iPhones etc)
It’s worth noting that the router doesn’t crash. Infact it’s webserver responds perfectly and LAN is not affected.
I can transmit UPD data from my Macbook to the Arduino and read it out on serial terminal.
My gf was streaming a movie from my laptop also which was not interrupted: So LAN and WiFi are still working.
I can also unplug the ethernet cable and in a few seconds, WAN is back.
The same issue happens whether DHCP is enabled or not and if tried many MAC addresses.
I know someone will ask for code so here it is, but given the evidence and what the OP experienced, this really feels like an electrical issue.
I’ve triple checked pins and I only have arduino and ECN28J60 connected, def no pin sharing.
Router is Netgear N300. No Ciscos here!

#include <EtherCard.h>
#include <IPAddress.h>

#define STATIC 0  // 1 to disable DHCP

#if STATIC
  static byte myip[] = { 192,168,0,30 };
  static byte gwip[] = { 192,168,0,1 };
#endif
  static byte mymac[] = { 0xEC,0xA7,0x94,0x9C,0x13,0xE0 };
  static int port = 8965;
byte Ethernet::buffer[500];

//Callback
void udpSerialPrint(word port, byte ip[4], word something, const char *data, word len) {
  IPAddress src(ip[0], ip[1], ip[2], ip[3]);
  Serial.println(data);
}

void setup(){
  Serial.begin(57600);
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println(F("Failed to access Ethernet controller"));
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println(F("DHCP failed"));
#endif
  ether.printIp("IP:  ", ether.myip);
  ether.udpServerListenOnPort(&udpSerialPrint, port);
}

void loop(){
 ether.packetLoop(ether.packetReceive());
}

Ok seems this problem only happens when the arduino (+ENC28J60) is powered by USB. Once I moved this project to a 10A 12V supply, it stopped crashing the router. Maybe the ENC28J60 needs more current to operated correctly.