Arduino Mega 2560 + Ethernet shield 2. Can't get ethernet to work.

Hello all!

I purchased and Arduino Mega 2560 and an Ethernet Shield 2 (which uses WIZ5500) from arduino.cc.

I am using the latest Arduino IDE downloaded from here. I have been trying to get the Ethernet to work using simple examples, but to no avail.

Here's what I've tried so far:

  1. I stacked the shield on top the mega board. I have not connected any other ports using jumper cables. I use an Ethernet cable to connect to my router. I ensured that the Ethernet cable works and can see LINK and ACT light up. I must stress here that whatever I tried, I have never seen LINK flashing (indicating that RX or TX activity is present).

  2. I use this simple example to check if SPI is working without any SD card present:

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);

void setup() {
  Serial.begin(9600);

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

  Serial.println("Starting w5500");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

This returns 0.0.0.0 and not the local IP. As you can see I've ensured that the SD module is disabled. I've also tested setting pins 10 and 53 to LOW without any success.

  1. If I test an SD card using the CardInfo example from the SD library, I can read the SD card fine.

  2. To ensure that ICSP is indeed mounted (and not hanging in the air) I've measured the pins 2 and 6 (+Vcc and Ground) and confirmed that a voltage of 4.8V appears.

  3. Even though I read that the current Ethernet library supports W5500 while this was not the case in the past, I nevertheless tested different libraries (Ethernet2, EthernetMod-W5x00, and Ethernet_W5500) but these tend to hang at

Ethernet.begin(mac);

and never return or continue - or return 0.0.0.0 as indicated above.

  1. I tracked down the part of the code where the Ethernet library fails - it doesn't detect the chip. In fact in this function taken from w5100.cpp
uint8_t W5100Class::isW5500(void)
{
	chip = 55;
	Serial.println("w5100.cpp: detect W5500 chip");
	if (!softReset()) return 0;
	Serial.println("WriteMR 0x08");
	writeMR(0x08);
	if (readMR() != 0x08) return 0;
	Serial.println("WriteMR 0x10");
	writeMR(0x10);
	if (readMR() != 0x10) return 0;
	Serial.println("WriteMR 0x00");
	writeMR(0x00);
	if (readMR() != 0x00) return 0;
	int ver = readVERSIONR_W5500();
	Serial.print("version=");
	Serial.println(ver);
	if (ver != 4) return 0;
	Serial.println("chip is W5500");
	return 1;
}

and using the default web-client example I get

Initialize Ethernet with DHCP:
w5100.cpp: detect W5500 chip
WriteMR 0x08
no chip :frowning:
Failed to configure Ethernet using DHCP
Ethernet shield was not found. Sorry, can't run without hardware. :frowning:

indicating that the W5100Class::isW5500 function does not successfully writeMR(0x08).

If anyone has any ideas or hints on what I should do next, I'd be very grateful.

Thanks a lot for taking the time to read this post!

the example looks old. do you use the latest version of the library (2.00)?

Many thanks for your reply, much appreciated.

I use the latest arduino IDE which ships with the default Ethernet library. In the folder where this is stored (at arduino's installation path) at the library.properties file I can confirm that I am using Ethernet version 2.0.0 which should work with W5500. Besides the simple example I posted at 2) I've also tested the WebClient example (among others) that ship with the default library. None of them work. At point 6) in my initial post I have posted the output of the WebClient example.

Is there anything I am missing?

add
Ethernet.init(10);
and if you have SD card inserted, remove it

Thanks!

I have already tried adding Ethernet.init(10) as this was commented out in the WebClient example (even though from my understanding this should by handled by the library itself) but failed to mention it in my initial post. It didn't work.

All of my tests are done without any SD card inside the slot. I have only inserted two different SD cards to ensure that the SPI bus works by trying the CardInfo example of the SD library.

4.8 V ? how is the board powered?

Through a USB A to USB B cable connected to a PC. I have not tried an external power source. I note that the Ethernet cable is connected to a router, not to the PC.

I tested the shield with an Arduino Uno board and got the same result, thus I think it is safe to conclude that if there is a problem it either lies with the Ethernet shield or I am doing something consistently wrong with the software. Granted that I've exhausted all libraries I could find through Google, and unless someone has any other suggestion on what I can test / check, I must say that I feel that the Ethernet shield is problematic. I will try to return it and/or test a new shield and will update this post accordingly.