ESPHome loses connection regularly, although connected via Ethernet

Hi,
I have an ESPHome set up that acts as a smart meter for my solar generator.
Because it is in the cellar and I don’t have a good WiFi connnection there, I used an Olimex Esp32-poe device and connected it via Ethernet cable.

The problem is, that the device loses connection on a regular basis - sometimes it works for some days and then the ESP is not reachable anymore.

In the Home Assistant logs I can see the following log entries:

2025-06-18 08:52:56.812 WARNING (MainThread) [aioesphomeapi.connection] esphome-smart-meter @ 192.168.20.20: Connection error occurred: Ping response not received after 90.0 seconds
2025-06-18 08:52:56.813 INFO (MainThread) [aioesphomeapi.reconnect_logic] Processing unexpected disconnect from ESPHome API for esphome-smart-meter @ 192.168.20.20

The only thing that helps is to power off/on the device.

What could be the problem here?

My ESP32Home script is like this:

esphome:
  name: esphome-smart-meter
  friendly_name: Smart Meter


esp32:
  board: esp32dev
  framework:
    type: arduino


# web_server:
#   port: 80
mqtt:
  broker: 192.168.0.2
  username: sensoren
  password: !secret mqtt_password_sensoren


# Enable logging
logger:
  level: DEBUG
  baud_rate: 0   # Important because we use the UART ports. Prevents warning "You're using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.""


# Enable Home Assistant API
api:


ota:
  - platform: esphome
    password: !secret ota_password


# wifi:
#  ssid: !secret wifi_ssid
#  password: !secret wifi_password
#
#  # Enable fallback hotspot (captive portal) in case wifi connection fails
#  ap:
#    ssid: "Esphome-Web-321864"
#    password: "TnrSQ8T6975Z"

# captive_portal:


# Ethernet configuration for Olimex ESP32-POE, see https://esphome.io/components/ethernet.html
ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
  power_pin: GPIO12
  manual_ip:
    static_ip: 192.168.20.20
    gateway: 192.168.20.1
    subnet: 255.255.255.0



# SML configuration
# See https://community.home-assistant.io/t/esp32-problem-with-two-uart-for-two-times-sml/529767
# See https://www.mittelstedt.net/?tag=esphome
# See https://wiki.volkszaehler.org/hardware/channels/meters/power/edl-ehz/iskraemeco_mt681 for the COM port settings.

# UART_0 uses GPIO3 (rx) and GPIO1 (tx). Should not be used because it is for the serial logger to the computer.
# UART_1 uses GPIO36 (rx) and GPIO4 (tx)
# NOT SURE!!!! UART_2 uses GPIO35 (rx) and GPIO33 (tx)
#     see https://github.com/espressif/arduino-esp32/blob/4638628873a061c36faffebe4d146d13f960076d/variants/esp32-poe-iso/pins_arduino.h

uart:
  - id: uart_01
    rx_pin: 3
    tx_pin: 1
    baud_rate: 9600
    # 8N1:
    data_bits: 8
    parity: NONE
    stop_bits: 1
    # debug:

  
  - id: uart_02
    rx_pin: 36
    tx_pin: 4
    baud_rate: 9600
    # 8N1:
    data_bits: 8
    parity: NONE
    stop_bits: 1
    # debug:
        
sml:
  - id: sml_01
    uart_id: uart_01
    
  - id: sml_02
    uart_id: uart_02

sensor:
# ----------- SML Netz -----------
  - platform: sml
    id: "netz_bezug_gesamt"
    name: "Netz Bezug gesamt"
    sml_id: sml_01
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    state_class: total_increasing
    device_class: energy
    filters:
      - multiply: 0.0001

  - platform: sml
    id: "netz_einspeisung_gesamt"
    name: "Netz Einspeisung gesamt"
    sml_id: sml_01
    obis_code: "1-0:2.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    state_class: total_increasing
    device_class: energy
    filters:
      - multiply: 0.0001

  - platform: sml
    id: "netz_bezug_aktuell"
    name: "Netz Bezug aktuell"
    sml_id: sml_01
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    accuracy_decimals: 0
    state_class: measurement
    device_class: power

    
# ----------- SML Z2 -----------
  - platform: sml
    id: "pv_wechselrichter"
    name: "PV Wechselrichter"
    sml_id: sml_02
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    state_class: total_increasing
    device_class: energy
    filters:
      - multiply: 0.0001   

  - platform: sml
    id: "pv_produktion_gesamt"
    name: "PV Produktion gesamt"
    sml_id: sml_02
    obis_code: "1-0:2.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 1
    state_class: total_increasing
    device_class: energy
    filters:
      - multiply: 0.0001   

  - platform: sml
    id: "pv_produktion_aktuell"
    name: "PV Produktion aktuell"
    sml_id: sml_02
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    accuracy_decimals: 0
    state_class: measurement
    device_class: power

Thanks for any help!

Hi

Having some Olimex PoE installed since years and without problem, I would suspect more a problem with the switch.
Are you sure the network cable is in good conditions ? what model of switch it’s connected to ?

Vincèn

I am seeing exactly the same issue, the device is powered on, but it seems to lose all connectivity, with the Ethernet port not communicating with the switch.

You’ll need to connect a usb/serial cable to it and check the console logs to see why it’s disconnecting

Will do, see what it shows

Also if you find its crashing Troubleshooting — ESPHome

I can’t see logs because serial logging is disabled (logger → baud_rate = 0).
If I remember correctly, I had to do that because I am using both UARTs for my SML sensors and my ESP32 didn’t start and was in a boot loop.

If you can’t get logs, it will be nearly impossible to figure out what is wrong. You have some choices:

  1. Find another way to have the device communicate to you what is going on.
  2. Put in a pre-emptive reboot. Once a day at 04:00 have it reboot itself.
  3. Use other techniques to figure out if the device is completely not responding or the network connection is just down.
  4. Add additional sensors to see the health of the node before it stops responding. I track the free memory on mine.

I have a node running something else that is somewhat problematic and it would regularly go out to lunch. I added a reboot timer to it and it can now go months without failing. I am in the process of moving it to esphome to have more control over the firmware to get a more permanent solution.

Alright I was able to record the logs. I cleared all the unrelated stuff and this is what I can see there:

ÔÉø[0;35m[C][mqtt.sensor:028]: MQTT Sensor 'Netz Bezug gesamt':ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:032]:   State Topic: 'esphome-smart-meter/sensor/netz_bezug_gesamt/state'ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:028]: MQTT Sensor 'Netz Einspeisung gesamt':ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:032]:   State Topic: 'esphome-smart-meter/sensor/netz_einspeisung_gesamt/state'ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:028]: MQTT Sensor 'Netz Bezug aktuell':ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:032]:   State Topic: 'esphome-smart-meter/sensor/netz_bezug_aktuell/state'ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:028]: MQTT Sensor 'PV Wechselrichter':ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:032]:   State Topic: 'esphome-smart-meter/sensor/pv_wechselrichter/state'ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:028]: MQTT Sensor 'PV Produktion gesamt':ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:032]:   State Topic: 'esphome-smart-meter/sensor/pv_produktion_gesamt/state'ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:028]: MQTT Sensor 'PV Produktion aktuell':ÔÉø[0m
ÔÉø[0;35m[C][mqtt.sensor:032]:   State Topic: 'esphome-smart-meter/sensor/pv_produktion_aktuell/state'ÔÉø[0m
ÔÉø[0;33m[W][api.connection:105]: ESPHome Logs 2025.2.2 (192.168.0.2): Connection closedÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:ÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt:  - loopTask (CPU 0)ÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt: Tasks currently running:ÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt: CPU 0: IDLE0ÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt: CPU 1: IDLE1ÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt: Aborting.ÔÉø[0m
ÔÉø[0;31mE (162776805) task_wdt: Print CPU 0 (current core) backtraceÔÉø[0m




Backtrace: 0x40084fcf:0x3ffb6730 0x400f8c59:0x3ffb6750 0x40087a43:0x3ffb6770




ELF file SHA256: 9562c6b9a6b88fb5

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7112
load:0x40078000,len:15624
load:0x40080400,len:4
load:0x40080404,len:3876
entry 0x4008064c
ÔÉø[0;32mI (29) boot: ESP-IDF 5.1.5 2nd stage bootloaderÔÉø[0m
ÔÉø[0;32mI (29) boot: compile time Jun 22 2025 09:35:43ÔÉø[0m
ÔÉø[0;32mI (29) boot: Multicore bootloaderÔÉø[0m
ÔÉø[0;32mI (33) boot: chip revision: v3.0ÔÉø[0m
ÔÉø[0;32mI (37) boot.esp32: SPI Speed      : 40MHzÔÉø[0m
ÔÉø[0;32mI (42) boot.esp32: SPI Mode       : DIOÔÉø[0m
ÔÉø[0;32mI (46) boot.esp32: SPI Flash Size : 4MBÔÉø[0m
ÔÉø[0;32mI (51) boot: Enabling RNG early entropy source...ÔÉø[0m
ÔÉø[0;32mI (56) boot: Partition Table:ÔÉø[0m
ÔÉø[0;32mI (60) boot: ## Label            Usage          Type ST Offset   LengthÔÉø[0m
ÔÉø[0;32mI (67) boot:  0 otadata          OTA data         01 00 00009000 00002000ÔÉø[0m
ÔÉø[0;32mI (75) boot:  1 phy_init         RF data          01 01 0000b000 00001000ÔÉø[0m
ÔÉø[0;32mI (82) boot:  2 app0             OTA app          00 10 00010000 001c0000ÔÉø[0m
ÔÉø[0;32mI (90) boot:  3 app1             OTA app          00 11 001d0000 001c0000ÔÉø[0m
ÔÉø[0;32mI (97) boot:  4 nvs              WiFi data        01 02 00390000 0006d000ÔÉø[0m
ÔÉø[0;32mI (105) boot: End of partition tableÔÉø[0m
ÔÉø[0;32mI (109) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=27608h (161288) mapÔÉø[0m
ÔÉø[0;32mI (176) esp_image: segment 1: paddr=00037630 vaddr=3ffb0000 size=021ech (  8684) loadÔÉø[0m
ÔÉø[0;32mI (179) esp_image: segment 2: paddr=00039824 vaddr=40080000 size=067f4h ( 26612) loadÔÉø[0m
ÔÉø[0;32mI (193) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=6ea5ch (453212) mapÔÉø[0m
ÔÉø[0;32mI (356) esp_image: segment 4: paddr=000aea84 vaddr=400867f4 size=06650h ( 26192) loadÔÉø[0m
ÔÉø[0;32mI (374) boot: Loaded app from partition at offset 0x10000ÔÉø[0m
ÔÉø[0;32mI (374) boot: Disabling RNG early entropy source...ÔÉø[0m
ÔÉø[0;32mI (386) cpu_start: Multicore appÔÉø[0m
ÔÉø[0;32mI (386) cpu_start: Pro cpu up.ÔÉø[0m
ÔÉø[0;32mI (387) cpu_start: Starting app cpu, entry point is 0x40081ce0ÔÉø[0m
ÔÉø[0;32mI (374) cpu_start: App cpu up.ÔÉø[0m
ÔÉø[0;32mI (404) cpu_start: Pro cpu start user codeÔÉø[0m
ÔÉø[0;32mI (404) cpu_start: cpu freq: 160000000 HzÔÉø[0m
ÔÉø[0;32mI (404) cpu_start: Application information:ÔÉø[0m
ÔÉø[0;32mI (409) cpu_start: Project name:     esphome-smart-meterÔÉø[0m
ÔÉø[0;32mI (415) cpu_start: App version:      2025.2.2ÔÉø[0m
ÔÉø[0;32mI (420) cpu_start: Compile time:     Jun 22 2025 09:34:01ÔÉø[0m
ÔÉø[0;32mI (426) cpu_start: ELF file SHA256:  9562c6b9a6b88fb5...ÔÉø[0m
ÔÉø[0;32mI (432) cpu_start: ESP-IDF:          5.1.5ÔÉø[0m
ÔÉø[0;32mI (437) cpu_start: Min chip rev:     v0.0ÔÉø[0m
ÔÉø[0;32mI (441) cpu_start: Max chip rev:     v3.99 ÔÉø[0m
ÔÉø[0;32mI (446) cpu_start: Chip rev:         v3.0ÔÉø[0m
ÔÉø[0;32mI (451) heap_init: Initializing. RAM available for dynamic allocation:ÔÉø[0m
ÔÉø[0;32mI (458) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAMÔÉø[0m
ÔÉø[0;32mI (464) heap_init: At 3FFB3E48 len 0002C1B8 (176 KiB): DRAMÔÉø[0m
ÔÉø[0;32mI (471) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAMÔÉø[0m
ÔÉø[0;32mI (477) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAMÔÉø[0m
ÔÉø[0;32mI (483) heap_init: At 4008CE44 len 000131BC (76 KiB): IRAMÔÉø[0m
ÔÉø[0;32mI (491) spi_flash: detected chip: genericÔÉø[0m
ÔÉø[0;32mI (494) spi_flash: flash io: dioÔÉø[0m
ÔÉø[0;32mI (499) app_start: Starting scheduler on CPU0ÔÉø[0m
ÔÉø[0;32mI (503) app_start: Starting scheduler on CPU1ÔÉø[0m
ÔÉø[0;32mI (503) main_task: Started on CPU0ÔÉø[0m
ÔÉø[0;32mI (513) main_task: Calling app_main()ÔÉø[0m
ÔÉø[0;32mIÔÉø[0;32m[I][logger:171]: Log initializedÔÉø[0m
ÔÉø[0;35m[C][safe_mode:079]: There have been 0 suspected unsuccessful boot attemptsÔÉø[0m
ÔÉø[0;36m[D][esp32.preferences:114]: Saving 1 preferences to flash...ÔÉø[0m
ÔÉø[0;36m[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failedÔÉø[0m
ÔÉø[0;32m[I][app:029]: Running through setup()...ÔÉø[0m
ÔÉø[0;35m[C][uart.idf:093]: Setting up UART 1...ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]: ÔÉø[0;32mI (676) uart: queue free spaces: 20ÔÉø[0m
ÔÉø[0m
ÔÉø[0;35m[C][uart.idf:093]: Setting up UART 2...ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]: ÔÉø[0;32mI (689) uart: queue free spaces: 20ÔÉø[0m
ÔÉø[0m
ÔÉø[0;35m[C][ethernet:041]: Setting up Ethernet...ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]: ÔÉø[0;32mI (1023) esp_eth.netif.netif_glue: 08:3a:f2:39:11:7fÔÉø[0m
ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]: ÔÉø[0;32mI (1024) esp_eth.netif.netif_glue: ethernet attached to netifÔÉø[0m
ÔÉø[0m
ÔÉø[0;32m[I][ethernet:248]: Starting ethernet connectionÔÉø[0m
ÔÉø[0;33m[W][component:157]: Component ethernet set Warning flag: waiting for IP configurationÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[sys_evt]ÔÉø[0;36m: ÔÉø[0;32mI (2604) esp_netif_handlers: eth ip: 192.168.20.20, mask: 255.255.255.0, gw: 192.168.20.1ÔÉø[0m
ÔÉø[0m
ÔÉø[0;32m[I][ethernet:259]: Connected via Ethernet!ÔÉø[0m
ÔÉø[0;35m[C][ethernet:515]:   IP Address: 192.168.20.20ÔÉø[0m
ÔÉø[0;35m[C][ethernet:516]:   Hostname: 'esphome-smart-meter'ÔÉø[0m
ÔÉø[0;35m[C][ethernet:517]:   Subnet: 255.255.255.0ÔÉø[0m
ÔÉø[0;35m[C][ethernet:518]:   Gateway: 192.168.20.1ÔÉø[0m
ÔÉø[0;35m[C][ethernet:523]:   DNS1: 0.0.0.0ÔÉø[0m
ÔÉø[0;35m[C][ethernet:524]:   DNS2: 0.0.0.0ÔÉø[0m
ÔÉø[0;35m[C][ethernet:536]:   MAC Address: 08:3A:F2:39:11:7CÔÉø[0m
ÔÉø[0;35m[C][ethernet:537]:   Is Full Duplex: YESÔÉø[0m
ÔÉø[0;35m[C][ethernet:538]:   Link Speed: 100ÔÉø[0m
ÔÉø[0;33m[W][component:170]: Component ethernet cleared Warning flagÔÉø[0m
ÔÉø[0;35m[C][mqtt:037]: Setting up MQTT...ÔÉø[0m
ÔÉø[0;36m[D][mqtt:514]: Enabling MQTT...ÔÉø[0m
ÔÉø[0;33m[W][component:157]: Component mqtt set Warning flag: unspecifiedÔÉø[0m
ÔÉø[0;32m[I][mqtt:250]: Connecting to MQTT...ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[mqtt_task]ÔÉø[0;36m: ÔÉø[0;31mE (4528) esp-tls: [sock=55] delayed connect error: Software caused connection abortÔÉø[0m
ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[mqtt_task]ÔÉø[0;36m: ÔÉø[0;31mE (4530) transport_base: Failed to open a new connection: 32772ÔÉø[0m
ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[mqtt_task]ÔÉø[0;36m: ÔÉø[0;31mE (4530) mqtt_client: Error transport connectÔÉø[0m
ÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:162]: MQTT_EVENT_ERRORÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:164]: Last error code reported from esp-tls: 0x8004ÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:165]: Last tls stack error number: 0x0ÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:166]: Last captured errno : 113 (Software caused connection abort)ÔÉø[0m
ÔÉø[0;33m[W][mqtt:340]: MQTT Disconnected: WiFi disconnected.ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[sys_evt]ÔÉø[0;36m: ÔÉø[0;32mI (10527) esp_netif_handlers: eth ip: 192.168.20.20, mask: 255.255.255.0, gw: 192.168.20.1ÔÉø[0m
ÔÉø[0m
ÔÉø[0;32m[I][ethernet:259]: Connected via Ethernet!ÔÉø[0m
ÔÉø[0;35m[C][ethernet:515]:   IP Address: 192.168.20.20ÔÉø[0m
ÔÉø[0;35m[C][ethernet:516]:   Hostname: 'esphome-smart-meter'ÔÉø[0m
ÔÉø[0;35m[C][ethernet:517]:   Subnet: 255.255.255.0ÔÉø[0m
ÔÉø[0;35m[C][ethernet:518]:   Gateway: 192.168.20.1ÔÉø[0m
ÔÉø[0;35m[C][ethernet:523]:   DNS1: 0.0.0.0ÔÉø[0m
ÔÉø[0;35m[C][ethernet:524]:   DNS2: 0.0.0.0ÔÉø[0m
ÔÉø[0;35m[C][ethernet:536]:   MAC Address: 08:3A:F2:39:11:7CÔÉø[0m
ÔÉø[0;35m[C][ethernet:537]:   Is Full Duplex: YESÔÉø[0m
ÔÉø[0;35m[C][ethernet:538]:   Link Speed: 100ÔÉø[0m
ÔÉø[0;33m[W][component:170]: Component ethernet cleared Warning flagÔÉø[0m
ÔÉø[0;32m[I][mqtt:250]: Connecting to MQTT...ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]: ÔÉø[0;32mI (10569) mqtt_client: Client asked to disconnectÔÉø[0m
ÔÉø[0m
ÔÉø[0;33m[W][ethernet:274]: Connection via Ethernet lost! Re-connecting...ÔÉø[0m
ÔÉø[0;33m[W][component:157]: Component ethernet set Warning flag: waiting for IP configurationÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[mqtt_task]ÔÉø[0;36m: ÔÉø[0;31mE (19533) esp-tls: [sock=55] connect() error: Host is unreachableÔÉø[0m
ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[mqtt_task]ÔÉø[0;36m: ÔÉø[0;31mE (19534) transport_base: Failed to open a new connection: 32772ÔÉø[0m
ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[mqtt_task]ÔÉø[0;36m: ÔÉø[0;31mE (19534) mqtt_client: Error transport connectÔÉø[0m
ÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:162]: MQTT_EVENT_ERRORÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:164]: Last error code reported from esp-tls: 0x8004ÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:165]: Last tls stack error number: 0x0ÔÉø[0m
ÔÉø[1;31m[E][mqtt.idf:166]: Last captured errno : 0 (Success)ÔÉø[0m
ÔÉø[0;33m[W][mqtt:340]: MQTT Disconnected: WiFi disconnected.ÔÉø[0m
ÔÉø[0;36m[D][esp-idf:000]ÔÉø[1;31m[sys_evt]ÔÉø[0;36m: ÔÉø[0;32mI (20526) esp_netif_handlers: eth ip: 192.168.20.20, mask: 255.255.255.0, gw: 192.168.20.1ÔÉø[0m

For some reason it rebooted and then the connect to the MQTT server failed.
How can I proceed from here?

I decoded the stacktrace now and it is this:

0x40084fcf: xt_utils_wait_for_intr at /data/cache/platformio/packages/framework-espidf/components/xtensa/include/xt_utils.h:81
0x40084fcf: esp_cpu_wait_for_intr at /data/cache/platformio/packages/framework-espidf/components/esp_hw_support/cpu.c:111
0x400f8c59: esp_vApplicationIdleHook at /data/cache/platformio/packages/framework-espidf/components/esp_system/freertos_hooks.c:59
0x40087a43: prvIdleTask at /data/cache/platformio/packages/framework-espidf/components/freertos/FreeRTOS-Kernel/tasks.c:4439

I searched for it and it is because the task watchdog detected a task that took too long (that’s also what the previous lines in the log file suggested: “Task watchdog got triggered.”).

What I could see in other places in my log file are lines like this:

ÔÉø[0;33m[W][component:237]: Component sml took a long time for an operation (65 ms).ÔÉø[0m
ÔÉø[0;33m[W][component:238]: Components should block for at most 30 ms.ÔÉø[0m

I believe that SML decoding sometimes takes too long so that the watchdog is triggered and restarts the device.

I will try to increase the watchdog timeout later today.
But: why can’t the ESP reconnect to the network after a reset? Is this a known issue?

I can feel you and your frustration with UART-reading.

I’ve done a lot of UART OBIS-stuff in the last months, so I suggest you debug first if the crashing/ unreponsiveness is related to memory being exhausted.

I’ve got fully working code for reading obis codes from uart with debug only for diffrent board, maybe you can learn from it also for your use case?

And maybe as you’re reading obis codes from UART, you might even use my modified esphome-component? Check it out too as it is much faster and more efficient than debugging UART, maybe it will work for you.

As I checked the nice and easy “how to” check ESPhome memory leaks and found not good one, I made one myself. Hope this help you track your project difficulties:

2 Likes

Thanks a lot @nikop ! Just flashed my ESPHome and I will have a look what’s going on here.

1 Like

@nikop with the increased watchdog timeout it took a bit longer now than before for the crash to appear.

The “Reason for last reset”-sensor shows “Unknown”, but for the free heap sensor I have the following diagram which shows me a spike down right before the device is not reachable anymore:

I suspect it is memory and I’ll try out your part 2, memory guard approach.

Having both mqtt and api may be part of your reboot problem if you did not integrate both mqtt and esphome api at the same time. There is a mechanism that if the api is not connected, it will reboot every 15 mins to see if that fixes it. There is a setting to prevent the rebooting, but if you do not intend to use the api because you use mqtt, just remove the api line.

@Edwin_D ouch, ok :-). I removed api now. Let’s see if it solves the issue.

I didn’t have the docs at hand when I first replied, but if you want to keep api then set the reboot_timeout to 0s:

In the beginning I needed it, but then at some time I used MQTT and don’t need it anymore.
Thanks for your help.