Hello, I recently added Ethernet PHY to my ESP32. It took sometime to get them working together but eventually they did.
I'm using the official Arduino Library for ESP32. When I assign a static IP address to ethernet it works perfectly fine and I can ping it normally and connect to it through a browser. However, If I don't assign an IP address, which normally means it should automatically obtain it, it prints the IP as 0.0.0.0
Below is my working code for initializing ethernet:
ETH.begin(PHY1, 17, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_IN);
ETH.config(IPAddress(192, 168, 16, 20), IPAddress(192, 168, 16, 1),
IPAddress(255, 255, 255, 0));
Serial.print("Ethernet IP:");
Serial.println(ETH.localIP());
now, if I remove ETH.config(), the IP obtained is 0.0.0.0
I did some digging into the ESP32 library , and I found in ETH.cpp a variable called staticIP which by default is equal to false, and it only changes to true if ETH.config() is called. So going by that code, my assumption should be true.
Any idea why ethernet is not automatically obtaining an IP? Thanks!!