FYI - network not working after ESP.restart()

Started by mihaiadrian, November 12, 2023, 04:07:12 AM

Previous topic - Next topic


Ok, so today I encountered and issue with ESP32 .  I was working fine with a 24 port Tp-link switch but NOT with a  Ubiquiti POE passthrough switch - after ESP.restart() there was no network. This was very annoying since I had to cut the switch power remotely in order to make the board back online.

I read this 2 links:
and found this workaround:

// workaround - some POE switches need this ....
void toggleNetwork() {
  digitalWrite(ETH_PHY_POWER, 0);

void restartBoard() {

So I call toggleNetwork before ETH.begin()  and  restartBoard() when I want to do a restart. With this 2 it seems to works fine for me , on both switches. ( only tested remotely ... hopefully I am not wrong )

Have fun.


Thanks for this info, and solution. However I think it is the function that you used that is the problem and the requirement of LAN getting initialized only after ESP32 had been initialized (so that it gets clock upon turning on). The Ethernet clock is generated by the ESP32.

1. Can you try to use ESP.reset() instead of ESP.restart() ?

2. Maybe instead of ESP.reset() and ESP.restart() can you try to toggle ESP_EN via your code?

Remember you have to take care of the sequence of powering. Ethernet has to start after ESP32's PHY clock is available.

Technical support and documentation manager at Olimex


Quote from: LubOlimex on November 13, 2023, 09:12:51 AM1. Can you try to use ESP.reset() instead of ESP.restart() ?

In function 'void restartBoard()':
error: 'class EspClass' has no member named 'reset'; did you mean 'restart'?

so I only have restart function available.


There was hardware reset for ESP8266 it was performed ESP.reset(), maybe it is not available for the ESP32. Huh, anyway software reset via ESP.restart() probably does exactly what I explained. It doesn't restart the Ethernet chip meaning it hangs (because it has no clock source) after the ESP32 chip performs software reset.
Technical support and documentation manager at Olimex


I added the following in setup(), now ESP32-POE reliably gets Ethernet connection and  on restart:

    digitalWrite(ETH_PHY_POWER, LOW);
    int success = ETH.begin();

Is there a better way to ensure that Ethernet doesn't start until after ESP32's PHY clock is available?


This is the best way, it is the reason to have a phy power enable/disable pin in first place.
Technical support and documentation manager at Olimex