Ethernet2 DHCP not working

I have a Mega2560 with an Ethernet2 shield. I've downloaded the Ethernet2 library from and to keep things as simple as possible I am using the basic "Web Server" demo application with the following changes;

  • #include Ethernet.h changed to Ethernet2.h
  • First parameter (mac address) removed from call to "Ethernet.begin()"
  • Ethernet2.h updated to #define WIZ550io_WITH_MACADDRESS

If I use the Ethernet.begin(IPAddress) overload, the application works as expected and I can connect to the device from any browser on the network implying that the hardware is working correctly.

If, however, I use the Ethernet.begin() version, requiring DHCP to be used, the device hangs for several tens of seconds then returns with zero, i.e. the call has failed.

I've added my own version of begin to Ethernet2.cpp which allows the mac address returned by w5500.getMACAddress() to be passed back to the setup function and Serial.printed. That returned value is It would therefore appear that w5500.getMACAddress is unable to read the preset MAC address from the device thus preventing the DHCP request failing.

DHCP is operating normally on the network.

Next step will be to write a sketch to interrogate the registers in the w5500 but before I embark on this time consuming exercise, does anyone out there know what may be going wrong?

you can install Ethernet2 with Library manager and it has own examples. no need to modify Ethernet examples

The examples with the Ethernet2 library all still use the form of 'begin' that require the MAC address to be supplied. I'm trying to avoid that so I can run multiple devices without having to hard code the MAC and IP addresses for every one. My shield has (or is supposed to have 'cos it's printed on a label on the board) its unique mac built in.

That said, even supplying the MAC address to .begin(mac) doesn't work. It returns very quickly and a call to Ethernet.locaIP() returns an IP address which curiously matches the first four bytes of the mac address.

I suspect it's a problem accessing the W5500 registers but I don't yet know enough about the overall architecture to comment. Also, if that is the problem, how does it manage to operate when I don't try to use DHCP?

Oh for a source code debugger

the MAC is not persistent in W5500

Hi Juraj,

Sorry, I don't quite understand what you mean by persistent. That is a word that can be interpreted in several ways depending upon context.

I think you are saying that the W5500 is shipped with the MAC written into NVRAM but this can be, and in my case probably has been, overwritten. Am I correct?


persistent (Wiktionary):

(computing) Of data or data structures: existing after the execution of the program. Remaining in existence past the lifetime of the program that creates it.

If that's the case, I don't quite understand the use of providing the module with an assigned mac address. Unless that information is stored somewhere on the module it's pretty pointless.

This also still doesn't address the main problem of DHCP not working and why reading back the IP address actually returned the first four bytes of the MAC address passed to .begin(), which is not not a valid IP address on my network.

We're not really getting very far in solving this one.