Esphome fails to connect to wifi after update

I did an OTA update with the latest esphome version to one of my nodemcu board which was working just fine before and now it fails to connect with these errors:

[10:23:22][W][wifi_esp8266:482]: Event: Disconnected ssid='NETGEAR' bssid=3C:7C:3F:xx:xx:xx reason='Auth Expired'
[10:23:22][W][wifi:536]: Error while connecting to network.
[10:23:22][W][wifi:571]: Restarting WiFi adapter...
[10:23:27][D][wifi:373]: Starting scan...

Code

esphome:
  name: solar-monitor
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pw
  output_power: 10

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  # ap:
  #   ssid: "Solar-Monitor Fallback Hotspot"
  #   password: "4MxW4Qbuzwxm"

captive_portal:

# Enable logging
logger:

ota:

# Enable Home Assistant API
api:

i2c:
  sda: D1
  scl: D2
  scan: true
display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    #reset_pin: D0
    #address: 0x3C
    lambda: |-
      auto now = id(esptime).now(); // local time
      if (now.hour < 8) {
        it.fill(COLOR_OFF);
      }
      else {
        if (id(solar_display).state) {
          it.printf(0, 0, id(calibri), "Solar Generation: %s", id(current_solar_generation).state.c_str());
          it.printf(0, 13, id(calibri), "Battery SOC: %s", id(solar_battery_soc).state.c_str());
          it.printf(0, 26, id(calibri), "Battery Power: %s", id(solar_battery_power).state.c_str());
          it.printf(0, 39, id(calibri), "House Load: %s", id(current_house_consumption).state.c_str());
          if (id(grid_status).state == "Exporting") {
            it.printf(0, 52, id(calibri), id(light_green), "Exporting: %s", id(current_grid_power).state.c_str());
          }
          else {
            it.printf(0, 52, id(calibri), id(light_red), "Importing: %s", id(current_grid_power).state.c_str());
          }
        }
        else {
          it.fill(COLOR_OFF);
        }
      }
font:
  - file: 'calibri.ttf'
    id: calibri
    size: 12

color:
  - id: light_red
    red: 100%
    green: 20%
    blue: 25%
    white: 0%
  - id: light_green
    red: 0%
    green: 100%
    blue: 25%
    white: 0%
    
time:
  - platform: homeassistant
    id: esptime
    
# sensor:
#   - platform: homeassistant
#     id: solar
#     entity_id: sensor.current_solar_generation
#     internal: true
    
text_sensor:
  - platform: homeassistant
    entity_id: sensor.current_solar_generation
    id: current_solar_generation
    internal: true
    
  - platform: homeassistant
    entity_id: sensor.solar_battery_soc
    id: solar_battery_soc
    internal: true
    
  - platform: homeassistant
    entity_id: sensor.current_house_consumption
    id: current_house_consumption
    internal: true
    
  - platform: homeassistant
    entity_id: sensor.current_grid_power
    id: current_grid_power
    internal: true
    
  - platform: homeassistant
    entity_id: sensor.grid_status
    id: grid_status
    internal: true
    
  - platform: homeassistant
    entity_id: sensor.solar_battery_power
    id: solar_battery_power
    internal: true

binary_sensor:
  - platform: homeassistant
    entity_id: input_boolean.solar_display
    id: solar_display
    internal: true    

Not sure how to fix it and bring the device online.
I had already updated 3 other devices without issues.
Any suggestions? I have already recompiled and uploaded FW via USB but no difference.

1 Like

I remember having the same issue once.
It was something in my yaml that it didn’t react to as wrong while compiling, but when I removed the part it worked.

I think it was something in the lambda display thing.
I would start there.

I think you can connect to the fallback wifi or with cable.

And… unless I have to do some change in the code, I don’t update my nodes.
It works so why update it :man_shrugging:

1 Like

Yeah lesson learnt, never updating these things again unless a must.
What about the lambda? Something changed with it recently? No idea what to look for

I don’t know.
My advice is to just cut it out and paste it in notepad, then add it piece by piece and see if that was the issue.

I have tired this. I went all the way to nothing and it seems to be when I add my display back in.
display:

  • platform: ssd1306_i2c
    model: “SSD1306 128x64”
    update_interval: 1s
    address: 0x3C
    id: my_display
1 Like

I had the same error, when I increased the update interval from 1s to 2s the problem was gone. It looks as if the device is more busy with updating the screen then making the wifi connection…

6 Likes

I have on ESP8266 that wouldn’t connect, same as yours.

I added a random GPIO switch (connected to nothing) and it compiled and connects fine. I can’t explain it but I’ve had this issue before, dodgy hardware?

Just odd.

This has been an issue for a while and no-one seems to be able to get to the bottom of it.

Having some weird wifi issues which might be related, my modem/router is not assigning any IPs via dhcp if I go static it works.
I tried setting the node to static ip however and still the same error about auth as above.
Mystery goes on

@towerclimber87 and @jsuanet thanks for the suggestion I tried update_interval: 3s and it started working again.
Never needed that before but maybe things changed with the later versions of esphome

I am dealing with two sonoff basics not connecting after i updated them today.
Is there any way to troubleshoot them if i dont have physical access to them? (they are enclosed in my garage door motors)

Perhaps if you connect to the fallback wifi?
Have never tried it though

1 Like

Good idea, ill check if its transmitting an ssid.

Also that update_interval: solution only works in the case of an lcd screen right?
Will it solve the issue on my sonoff basic? if so, in which block of code do i add it?

For those whose also have this issue BUT do not want to have an update_interval of 2s, the solution described here, by changing the I²C Bus frequency to 800kHz, worked for me and I was able to keep the default update_interval of 1s.