i have one ESP32-POE and ESP32-POE and i'm using the Olimex RS485 module to read a power meter that is placed near the ESP32 (5 meters of CAT5 cable - 9600 8N1).

My device has this workflow (it's powered via PoE using a Cisco 2960x switch):

  • Boot and acquire a DHCP address
  • Connect to the server and check if there is a new ota package to download
  • Read via modbus (Using ModbusMaster library) the power meter
  • Prepare the data in JSON format using ArduinoJson library and send it to the broker using PubSubClient
  • Wait for five minutes using Millis and start over with the loop

This is the main logic that "blocks" the loop and wait for some minutes:

void loop() {

  client_subscriber_loop(); // loop subscriber mqtt

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillisTaskDataPublisher > MQTT_PUBLISH_EVERY) {
    if (DEBUG == 1)
      Serial.printf("Free internal heap on Loop Enter %u\n", ESP.getFreeHeap());
    //  OTA Check

    if (DEBUG == 1)
      Serial.printf("Free internal heap on Loop Enter %u\n", ESP.getFreeHeap());

    previousMillisTaskDataPublisher = currentMillis;

As you can see, i've also have Watchdog timer enabled and it is feeded in the loop or function that have to feed it (Modbus read, etc...)

Now, here comes the issues, this works exactly for 10 days and after that the MCU goes in loop, the LAN green led will flash indefinitely and nothing work, leaving the ESP32 in a undefined state.

This is the debug message that i see on arduino console:

Arduino console

There is no way to make it work a part of power off and power on the device.

This is extremely uncomfortable...in my case i have 25 of those devices placed far away from my office (600km) and i can't go every time to reboot them every ten days.

Maybe is hardware related issue? a software issue on ModbusMaster library?

Any toughts?

  • please, no pictures of text ... include the debug message as text ... format it the sane as code
    – jsotola
    Commented Aug 6, 2020 at 14:19
  • You could have the watchdog timer timeout if you get a network error. Then the MCU will just reset. It would be interesting to see if lowering MQTT_PUBLISH_EVERY also make the problem occur faster than 10 days.
    – Gerben
    Commented Aug 6, 2020 at 14:48
  • Is the console output from right before the ESP malfunctions? There is no way to make it work a part of power off and power on the device. does that include pressing the reset button?
    – Gerben
    Commented Aug 6, 2020 at 14:49
  • Have you considered performing a software reset every 24h as a workaround?
    – Sim Son
    Commented Aug 6, 2020 at 17:47
  • Tomorrow I'll remove the publish delay and test it. - about what asked from Gerben, yes, this is the console output right before the ESP malfunction, it doesn't include the reset pressing button (if I reset the device with reset button it will start working).
    – SardoMan
    Commented Aug 6, 2020 at 20:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.