ESPHome - Wifi - Auth Expired

Wow - that’s interesting! Could this be a power consumption issue?

I did some more testing today and the issue for me appears to be the lambda code. If I remove that, the wifi connection works every time. If I add it back in - it fails, most of the time. It doesn’t matter what I try to display. E.g. only using the line “Initialising…” stops it from working.

Any thoughts how I can get around this?

@doubledutch Sorry I miss getting back

I know you probably done all this but just lets try and check the ESP because of your last post.

Are you running the latest ESPHome? If not maybe a good idea to update.

Try work through each step… if you are good go to the next one.

1/ Are you close to your Access point? If not get really close… just trying to eliminate your ESP wi-fi.
2/ Have you done a clean build? If not maybe try this. On the 3 dots select “Clean Build Files”.
3/ Can you back up your code and just put in the basic information with a clean build. I added some stuff and changed some things

esphome:
  name: kitchen_display
  platform: ESP8266
  board: d1_mini_pro

wifi: # Note this change try keep it symple
  ssid: !secret wifi_ssid
  password: !secret wifi_password

#  manual_ip:
#    static_ip: 192.168.1.20
#    gateway: 192.168.1.254
#    subnet: 255.255.255.0

  ap:
    ssid: "kitchen_display"
    password: password

logger:

api: #do you have a api password?
#  password: !secret esphome_secret

ota:

If this is stable then add your “i2C”…install test…then add your “sensor”…install test…then add your “binary_sensor”…install test… then add your “display”…install test…then your “time”… test. Lets try see if there is the fault where.

4/ If option 3 fails, do you have another ESP that you can try the same code on it? If so try this.

Hi @Blacky - Thanks for your reply. With regards to your suggestions:

  1. I moved it to multiple locations, using different access points (I have 4) - no difference
  2. I have - I have even changed all the hardware
  3. Removing the lamda section makes it connect straight away and I spend all last night removing/adding settings to my code, so not sure that’s a solution?
  4. See (2) - I already changes the hardware and that made no difference

What does happen is that this “Auth Expired” happens but if I just leave it on, sometimes for hours, it sometimes, finally connects but when we reboot the device for any reason: we start again

1 Like

@doubledutch Is your code like this note the wifi

esphome:
  name: kitchen_display
  platform: ESP8266
  board: d1_mini_pro

wifi: # Note this change try keep it symple
  ssid: !secret wifi_ssid
  password: !secret wifi_password

#  manual_ip:
#    static_ip: 192.168.1.20
#    gateway: 192.168.1.254
#    subnet: 255.255.255.0

  ap:
    ssid: "kitchen_display"
    password: password

logger:

api: #do you have a api password?
#  password: !secret esphome_secret

ota:

can you show us the code you remove… show with code and without code 2 examples.

Hi @Blacky - I tried making the suggested network changes previously and using DHCP instead of static IP but it made no difference. I was playing around with this for hours last night and concluded that the configuration below (removing lambda) made all the difference. I then changed everything back, left it overnight and it was connected again in the morning. When you asked the question just now, took this lambda code out again, did a clean compile and the device, unfortunately, is back in its Auth Expired loop without the lambda code being present so I’m afraid: I’m clutching at straws. I’m sorry and really not sure what is going on (just to be clear - the code below worked last night but doesn’t work today anymore so I will leave it a couple of hours to see if it reconnects)

esphome:
  name: kitchen_display
  platform: ESP8266
  board: d1_mini_pro

wifi:
  manual_ip:
    static_ip: 192.168.1.20
    gateway: 192.168.1.254
    subnet: 255.255.255.0
  
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password

logger:

api:

ota:

i2c:
  sda: D2
  scl: D1
  scan: true
  
sensor:
  - platform: homeassistant
    id: outside_humidity
    entity_id: sensor.outside_humidity
    internal: true
  - platform: homeassistant
    id: outside_temp
    entity_id: sensor.outside_temperature
    internal: true
  - platform: homeassistant
    id: outside_illuminance
    entity_id: sensor.outside_illuminance
    internal: true
  - platform: homeassistant
    id: outside_max_temp
    entity_id: sensor.weather_today_max_temp
    internal: true
  - platform: homeassistant
    id: outside_min_temp
    entity_id: sensor.weather_today_min_temp
    internal: true
  - platform: homeassistant
    id: kitchen_pressure
    entity_id: sensor.kitchen_pressure
    internal: true
  - platform: homeassistant
    id: kitchen_temp
    entity_id: sensor.kitchen_temperature
    internal: true
  - platform: bme280
    temperature:
      name: "Kitchen Temperature"
      oversampling: 16x
      filters:
      - calibrate_linear:
      #    # Map 0.0 (from sensor) to 0.0 (true value)
          - 27.5 -> 24.5
          - 20.0 -> 18.6
          - 18.8 -> 17.0
          - 19.2 -> 17.6
    pressure:
      name: "Kitchen Pressure"
    address: 0x76
    update_interval: 20s
binary_sensor:
  - platform: gpio
    pin: 14
    name: "PIR Sensor"
    device_class: motion
    on_press:
      then:
        - binary_sensor.template.publish:
            id: backlight
            state: ON
        - binary_sensor.template.publish:
            id: backlight
            state: OFF
  - platform: template
    id: backlight
    filters:
      - delayed_off: 90s
    on_press:
      then:
        - lambda: |-
            id(my_display).backlight();
            //id(my_display).no_backlight();
            // it.print(0,19,".");
    on_release:
      then:
        - lambda: |-
            id(my_display).no_backlight();
            // it.print(0,19," ");
display:
  - platform: lcd_pcf8574
    id: my_display
    dimensions: 20x4
    address: 0x27
#    lambda: |-
#    
#      // How to use character based display: https://esphome.io/components/display/lcd_display.html
#      
#      // id(my_display).no_backlight();
#      //  Check above link to see how to manage backlight using motion sensor
#      
#      it.print(0,0,"Initializing...");
#
#      // Print the current time
#      auto timeVar = id(homeassistant_time).now();
#      if (timeVar.is_valid()) {
#        it.strftime(0,1,"%H:%M:%S  ",timeVar);
#        it.printf(13,1,"%4.0f lx",     id(outside_illuminance).state);
#        it.strftime(0,0,"%a %d %b %Y", timeVar);
#        // Result for 10:06 on august 21st 2018 -> "It is 10:06 on 21.08.2018"
#      }

#      // Outside Measurements
#      // Example of how to display homeassistant data in ESPHome: https://esphome.io/cookbook/display_time_temp_oled.html
      
#      //  sensor.outside_temperature
#      if (id(outside_temp).has_state()) {
#        if (id(outside_temp).state < 10) {
#          it.printf(0,2,"Out:  %02.1f", id(outside_temp).state);
#        }
#        else {
#          it.printf(0,2,"Out: %02.1f", id(outside_temp).state);
#        }
#      }

#      if ((id(outside_min_temp).has_state()) && (id(outside_max_temp).has_state())) {
#          it.printf(9,2," (%0.0f to %0.0f)  ", id(outside_min_temp).state,id(outside_max_temp).state);
#      }


#      if (id(kitchen_temp).has_state()) {
#        it.printf(0,3,"In : %02.1f", id(kitchen_temp).state);
#      }
      
#      if (id(outside_humidity).has_state()) {
#        it.printf(12,3,"Hum: %02.0f%%", id(outside_humidity).state);
#        //it.print(19,3,"%");
#      }
      

# (Optional) For displaying time:
time:
  - platform: homeassistant
    id: homeassistant_time

@doubledutch Can you try this update_interval

from this

display:
  - platform: lcd_pcf8574
    id: my_display
    dimensions: 20x4
    address: 0x27

to this

display:
  - platform: lcd_pcf8574
    id: my_display
    dimensions: 20x4
    address: 0x27
    update_interval: 2s
8 Likes

Hi @Blacky - done and in the one re-start that I did, it worked perfectly. Wifi connected straight away with no Auth Expired.

Could you explain why that may be?

I will monitor and provide more feedback if I receive it and thank you so much for your help!

@doubledutch

Default is 1s so we just gave it time so it can make wi-fi connection.

you should be good to go now :+1:

after you monitor it and find this has resolved it make sure you mark it solve so others and jump directly to the solution. :wink:

Will absolutely do so. Thanks again!

1 Like

@Blacky tried resetting the unit a few times and it worked every time so “Solution” is updated in this post and thanks again for your help.

1 Like

I just read here: SSD1306 breaks wi-fi - #3 by jsuanet that someone had similar problem with SSD1306. One of reccomended solutions there was also to increase I2C frequency - you can try that, too.

Wow thanks for this hint :smiley:
I have the same problem with my Wemos D1 mini v3.0.0 and I can confirm that the I2C frequency hack works.
It doesnt matter if you use I2C or not but adding these lines made wifi work again:

i2c:
  sda: GPIO3
  scl: GPIO1
  frequency: 800kHz

This problem also accoured only for the v3.0.0. I generally use the v2 wemos boards and none of them had this issue.

2 Likes

Thanks for this! It’s solved my wifi connection issue but now does mean once connected the display refresh is a bit slow. This is normally fine but my screen is reacting to a rotary encoder (with possible gif) so I could do with it being speedy. Is there a way to say “once connected drop this back to 1s” at all?

Edit… For anyone looking for the answer to my post. This is what works for me and allows me to have a display refresh rate of 0.1s. For some reason I still needed the frequency bit, even with the wait on boot.

esphome:
  name: "blah"
  on_boot:
    priority: 200  
    then:
      - wait_until:  
          condition:
            wifi.connected: 
          timeout: 5s

# Display
i2c:
  sda: D7
  scl: D6
  frequency: 200kHz
2 Likes

I had this, and fixed it, by connecting the ESP to a 2.4 GHz network and selecting “Legacy” wireless mode on my router (which is an Asus ZenWiFi AX). My hypothesis is that the WiFi driver is incompatible with one of the 802.11 a/b/g/n/ac protocols.

1 Like

WOW !!!

It´s works for me too.

I´m having trouble with I2C SH1106. With display plugged, wifi can´t connect.

With your code, works !!!

Thaks

1 Like

Hi, do not understand the solution flagged?

does this solve the wifi auth expired?

I assume not.

having also same error but no no i2c device, not even any

I recently encountered this sort of issue when making some network changes. All of a sudden 3 esphome devices and 3 tasmota plugs started having connectivity issues. Each esphome device would spew out various “auth expired”, “4-way handshake timeout”, “authentication failed”, “probe request unsuccessful” and other wifi errors.

After trying a bunch of recommended fixes and getting nothing working, I realized that my router had automatically changed to channel 11, near the end of the range. Seeing as some people mentioned noise/interference causing these issues, I tried changing this to channel 5, closer to the middle of the road, and suddenly all of the devices stopped having issues. So, I’m pretty sure that’s part of the problem.

Did anyone get a solution for this? Got another pack of ESP32-S2 (S2 Mini) and could not get them to connect to Wifi because of “Auth expired” errors…

I had this issue and determined mine to be caused by band steering on my wifi/router. That is when the 2.4 Ghz wifi delays its response to your esp32 so that the 5ghz can respond first and try to get you to associate there instead. Unfortunately I could not turn this off on my wifi router but was able to work around it by specifying the BSSID to connect to in the esphome wifi config. And used the BSSID specific to the 2.4 Ghz radio along with fast connect setting.

Ended up ditching that router/wifi though after a while and getting something else.

1 Like