ESP32 disconnects from the network randomly

Good afternoon, I have an ESP32 with the code below, and it disconnects from the network randomly and does not turn back on. It’s working fine for hours, and then it goes offline.

  • I already changed the power supply
  • I have already seen the WIFI AP settings
  • I can see the logs
  name: esp32-anexo2

  board: esp32dev
    type: arduino

# Enable logging
  level: debug

# Enable Home Assistant API
    key: "***"

  password: "***"

  ssid: !secret wifi_ssid
  password: !secret wifi_password
    static_ip: 192.168.1.**
    gateway: 192.168.1.***
    subnet: ***.***.***.*

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Esp32-Anexo2 Fallback Hotspot"
    password: "**"


  sda: 21
  scl: 22
  scan: true


  - platform: bme280
      name: "**"
        - offset: 0.7
      name: "**"
      accuracy_decimals: 0
        - offset: 2.35
    address: 0x76 
    update_interval: 300s

  - platform: atc_mithermometer
    mac_address: "**:**:**:**:**:**"
      name: "ATC Temperature"
      name: "ATC Humidity"
      name: "ATC Battery-Level"
      name: "ATC Battery-Voltage"
      name: "ATC Signal"  

  - platform: gpio
    pin: 13
    name: "***"
    device_class: motion
Logger: aioesphomeapi.connection
First occurred: 17 de dezembro de 2023 às 18:15:31 (9 occurrences)
Last logged: 00:28:49

esp32-anexo2 @ 192.168.1.***: Connection error occurred: [Errno 104] Connection reset by peer
esp32-anexo2 @ 192.168.1.***: Connection error occurred: Ping response not received after 90.0 seconds

Add this sensor:

What values do you get before it disconnects?

Also there is no need to obscure local IP addresses. They are not routable on the Internet.

thanks for trying to help.

I’ve already monitored the signal strength, and didn’t find anything relevant. the signal always remains good until the connection is lost.

How are you measuring that and what relation does % have to dBm?

Just to rule it out, you may want to add the following to your WiFi section


A few years ago, when I first started with ESPHome, I had to disable the WiFi power saving in order to keep the ESP32 microcontroller connected reliably.

1 Like

I had to do the same and remove power saving for all of my ESP32 nodes. Most of them have a signal strength between -52dbm and -64dbm but they would periodically and randomly disconnect then reboot. Once I turned off power saving they stay connected all the time. I did have to disable the web server on one of them as well due to it causing the Wi-Fi stack to lose interrupt timing and cause comms issues. If there’s too much the ESP is doing, it can’t do everything it needs to do when it needs to do it and Wi-Fi comms is one of those things that can’t be delayed or something views it as a hung client or unresponsive client and it either gets kicked off the network or it reboots.



  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"
    device_class: ""

Your 80% signal level corresponds to -60dBm. Which is good. So that’s not your issue.

Yes, I had already created this sensor to rule this out.

Thanks for the tip. I’ll change it and give you feedback later. I didn’t change this because I had to compare it with another esp32 that has the same configuration and has power_save_mode: in light and I have no problems with that other one. But, as no two esp are alike, you may be right. I’ll try. Thanks

Yeah but it gave an arbitrary % value that means nothing to me as I did not know how it was calculated. I was just checking. For reference:

That -70dBm signal level corresponds to 60% on your scale, you should aim for that as a minimum.

The power_save_mode: NONE does not work with esp32_ble. I had already looked at github and a solution would be to change the Arduino version to 1.0.4, but this version is already from 2018 and gives an error when installing

Captura de ecrã 2023-12-19 115345

1 Like