I am trying to get an ESP32 DevkitC V4 to run with a W5500 module - I need a wired Ethernet connection unfortunately. The code (stripped to the relevant parts) is like this:
...
// SPI for W5500 Ethernet module
#include <SPI.h>
#include <IPAddress.h>
#include <Ethernet.h>
...
// Variables for Ethernet.h
byte mac[] = { 0x30, 0x2B, 0x2D, 0x35, 0x51, 0xA2 };
IPAddress ip(192,168,178,141);
IPAddress myDns(192,168,178,1);
IPAddress gateway(192,168,178,1);
IPAddress subnet(255,255,255,0);
...
// start the Ethernet connection:
Serial.println("Trying to get an IP address using DHCP");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
}
else
{
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
else
{
// initialize the Ethernet device not using DHCP:
Ethernet.begin(mac, ip, myDns, gateway, subnet);
}
}
}
// print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
...
(this is basically the example code from the Ethernet.h library)
After power up, the yellow LED on the RJ45 jack starts blinking slowly. 30 seconds later the DHCP request is terminated and the according messages are printed:
Trying to get an IP address using DHCP
Failed to configure Ethernet using DHCP
My IP address: 192.168.178.141
Now the yellow LED is steadily on, the green traffic LED is signalling data traffic. But the device is not visible in the network at all (the router is an AVM Fritz.box).
I do not expect it to react on ping requests (no ICMP), but I thought it must be known to the router? And why does DHCP fail? It is working flawlessly with other devices in the network.