Device won't connect after wireless access point replacement

I have two Sonoff 4CHPRO R3 relays running ESPHome. They are operating garage doors in two separate buildings and have been working fine for about six months. A couple of days ago, I upgraded the wireless access point in one of the buildings. The Sonoff relay in that building will no longer connect.

I’m pretty sure the issue is not with the relay.

  • I am able to connect to it using a USB CH340 device.
  • If I switch back to the old access point, the relay connects to wifi immediately.

The network settings are managed by my network controller so there is no chance that the ssid or password is wrong. The new wireless access point is the same model that the other relay connects to quite successfully. I’ve tried a number of combinations of wifi frequency and channel width with no success.

If I ping the relay, the pings timeout. The log for the relay looks like this:

`I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[W][wifi:689]: Restarting WiFi adapter...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[W][wifi:689]: Restarting WiFi adapter...
[D][wifi:481]: Starting scan...
[D][wifi:496]: Found networks:
[I][wifi:539]: - 'IoT' (EE:FA:C4:0F:B0:1E) [redacted]▂▄▆█
[D][wifi:541]:     Channel: 6
[D][wifi:542]:     RSSI: -80 dB
[I][wifi:539]: - 'IoT' (A2:25:4A:57:25:44) [redacted]▂▄▆█
[D][wifi:541]:     Channel: 11
[D][wifi:542]:     RSSI: -87 dB
[I][wifi:539]: - 'IoT' (7E:FE:CE:CE:20:94) [redacted]▂▄▆█
[D][wifi:541]:     Channel: 1
[D][wifi:542]:     RSSI: -61 dB
[D][wifi:544]: - 'NicoNet'[redacted] (7A:FE:CE:CE:20:94) [redacted]▂▄▆█
[D][wifi:544]: - 'NicoNet_EXT'[redacted] (40:EE:15:E4:62:2C) [redacted]▂▄▆█
[D][wifi:544]: - 'LilyNet'[redacted] (74:FE:CE:CE:20:94) [redacted]▂▄▆█
[D][wifi:544]: - ''[redacted] (EA:FA:C4:0F:B0:1E) [redacted]▂▄▆█
[D][wifi:544]: - 'NicoNet'[redacted] (E4:FA:C4:0F:B0:1E) [redacted]▂▄▆█
[D][wifi:544]: - 'Cameras'[redacted] (F2:FA:C4:0F:B0:1E) [redacted]▂▄▆█
[D][wifi:544]: - 'NicoNet'[redacted] (40:ED:00:BA:8B:3A) [redacted]▂▄▆█
[D][wifi:544]: - ''[redacted] (9E:25:4A:57:25:44) [redacted]▂▄▆█
[D][wifi:544]: - 'NicoNet'[redacted] (98:25:4A:57:25:44) [redacted]▂▄▆█
[D][wifi:544]: - 'Cameras'[redacted] (A6:25:4A:57:25:44) [redacted]▂▄▆█
[D][wifi:544]: - ''[redacted] (56:96:04:68:16:54) [redacted]▂▄▆█
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=EE:FA:C4:0F:B0:1E[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=EE:FA:C4:0F:B0:1E[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=EE:FA:C4:0F:B0:1E[redacted] reason='Authentication Failed'`

The different BSSIDs for the same network ID result from multiple WAPs. During my hours of troubleshooting, at one point I was getting a message in the logs along the lines of “component mdns took a long time for an operation”.

Here is the wifi section of the ESPHome code for the device:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.30.71
    gateway: 192.168.30.1
    subnet: 255.255.254.0

Both relays are meant to use the ‘IoT’ network, which is broadcasting only 2.4 GHz. The router is set to reserve 192.168.30.71 for the relay that is not connecting.

Other devices in that building connect to the new WAP without issue.

I know the relay is not connecting to the network because the device does not appear in the clients list of my network controller, the blue light on the relay is not illuminated, and my HA automations that interact with this relay do not work.

Any ideas for solutions to this issue?

Hi, did you try to connect another device to that new AP, just as a test?

An authentication issue is shown in your logs. Are yo usure that the password to connect is correct on this new AP. Depending on how old the other AP is maybe it is configured for a different security method?

Yes, thanks for asking that. I forgot to mention it in my original post. All other devices in that building connect to the new WAP (many on the IoT network) without issue.

Configuration of the wireless networks (SSIDs, passwords, security mode, etc) are stored in the network controller. All I do is pick which networks I want the WAP to broadcast. The password is not the issue.

Could this be a timing issue? Failure to navigate the handshake within a time limit? How do I give the device more time to connect?

You don’t say which AP you are using, but in mine (Omada) I can specify the AP that a WiFi client should use. Also, try cycling the AP power.

I upgraded from a TP-Link EAP245 to an EAP610.
Thanks for the suggestion on cycling the power. I tried that numerous times during my troubleshooting effort yesterday.
As for specifying which AP a client should use, that can only be done in the client config screen, to my knowledge. The device must first connect to the network to become a client, which is my main issue here.

Duh. I missed the obvious. You have the same EAPs that I do and I have noticed that clients are sometimes slow to find the closest EAP.

Forgive me for asking something you have already stated.
Try changing you logger level to verbose. It may reveal something you missed.
Is there NO CHANCE that the IP is already in use? Unplug the Sonoff and try to ping it.

I changed the logging level to verbose and removed the static IP portion of the ESPHome code. I also stopped the router from assigning a static address to the device. Here is the new code in full:

esphome:
  name: "shop-opener"   # Name of the Node.
  platform: ESP8266      # Even if the chip is a ESP8285, they have the same family.
  board: esp01_1m
  on_boot:
    priority: -100
    then:
      light.turn_on:
        id: status_led

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true


api:

logger:
  level: VERBOSE

ota:
  platform: esphome

binary_sensor:
  - platform: gpio
    on_press:
      then:
        - switch.turn_on: button_1
        - delay: 0.5s
        - switch.turn_off: button_1
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "Shop Button 1"
  - platform: gpio
    on_press:
      then:
        - switch.turn_on: button_2
        - delay: 0.5s
        - switch.turn_off: button_2
    pin:
      number: GPIO9
      mode: INPUT_PULLUP
      inverted: True
    name: "Shop Button 2"
  - platform: gpio
    on_press:
      then:
        - switch.turn_on: button_3
        - delay: 0.5s
        - switch.turn_off: button_3
    pin:
      number: GPIO10
      mode: INPUT_PULLUP
      inverted: True
    name: "Shop Button 3"
  - platform: gpio
    on_press:
      then:
        - switch.turn_on: button_4
        - delay: 0.5s
        - switch.turn_off: button_4
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: True
    name: "Shop Button 4"
  - platform: status
    name: "Garage Status"

switch:
  - platform: gpio
    id: button_1
    name: "Shop Relay 1"
    pin: GPIO12
  - platform: gpio
    id: button_2
    name: "Shop Relay 2"
    pin: GPIO5
  - platform: gpio
    id: button_3
    name: "Shop Relay 3"
    pin: GPIO4
  - platform: gpio
    id: button_4
    name: "Shop Relay 4"
    pin: GPIO15

output:
  - platform: esp8266_pwm
    id: blue_led
    pin: GPIO13
    inverted: True

light:
  - platform: monochromatic
    id: status_led
    name: "Garage Blue LED"
    output: blue_led

Here are the results:

state: 0 -> 2 (b0)
state: 2 -> 0 (0)
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
wifi evt: 1
STA disconnect: 202
[W][wifi:652]: Error while connecting to network.
[W][wifi:689]: Restarting WiFi adapter...
[V][wifi_esp8266:063]: Disabling STA.
del if0
usl
mode : null
force[V][wifi_esp8266:556]: Event: Changed Mode old=STA new=OFF
wifi evt: 8
 slp enable,type: 2
[I][wifi:312]: WiFi Connecting to 'IoT'...
[V][wifi:314]: Connection Params:
[V][wifi:315]:   SSID: 'IoT'
[V][wifi:320]:   BSSID: Not Set
[V][wifi:348]:   Password: ''[redacted]
[V][wifi:355]:   Channel: Not Set
[V][wifi:362]:   Using DHCP IP
[V][wifi:364]:   Hidden: NO
[V][wifi_esp8266:061]: Enabling STA.
mode : sta(34:98:7a:c7:f5:c1)
add if0
[V][wifi_esp8266:556]: Event: Changed Mode old=OFF new=STA
wifi evt: 8
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
wifi evt: 1
STA disconnect: 202
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[V][wifi:314]: Connection Params:
[V][wifi:315]:   SSID: 'IoT'
[V][wifi:320]:   BSSID: Not Set
[V][wifi:348]:   Password: ''[redacted]
[V][wifi:355]:   Channel: Not Set
[V][wifi:362]:   Using DHCP IP
[V][wifi:364]:   Hidden: NO
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
[W][wifi_esp8266:504]: Event: Disconnected ssid='IoT' bssid=7E:FE:CE:CE:20:94[redacted] reason='Authentication Failed'
wifi evt: 1
STA disconnect: 202
[W][wifi:652]: Error while connecting to network.
[D][wifi:696]: Retrying with hidden networks...
[I][wifi:312]: WiFi Connecting to 'IoT'...
[V][wifi:314]: Connection Params:
[V][wifi:315]:   SSID: 'IoT'
[V][wifi:320]:   BSSID: Not Set
[V][wifi:348]:   Password: ''[redacted]
[V][wifi:355]:   Channel: Not Set
[V][wifi:362]:   Using DHCP IP
[V][wifi:364]:   Hidden: NO

The static IP address was not being assigned to another device. It was not listed among my clients. Pinging it returned failed results.

I’ve tried connecting to another known good network. No dice.
I rebooted the network controller and all of the switches, WAPs, and router. No dice.

AI says it’s an authentication failure.
It’s a long shot, but delete:

fast_connect: true

It is my weak recollection that fast_connect: true uses WiFi credentials stored on the device.

On a slight tangent- I have a few ESP devices that just will not connect to WiFi when flashed with EspHome Version 2024.x, but the error I get in the log after all WiFi APs are scanned is “No networks found”. But, static IP fixes that. I do not usually use static IP because I have over 120 clients on my network and managing that many IP addresses would be difficult. (Only my servers have a static IP. Most of my IOT clients have a reserved IP in the router.)
Another fix to my new issue is to use an older version of ESPHome (2023.9) to compile the binary. If you wish, I could compile your configuration on 2023.9 and email the .bin file to you.

At this point- maybe buy a spare Sonoff switch?

Solved it! I had previously bound the Sonoff relay to the WAP that I had taken out of service. That meant it was the only access point to which it would connect. I discovered this because I got searching through the controller settings to ensure I hadn’t blocked the device.

Lesson learned. Be cautious about assigning devices to a certain access point, or at least know you’ve done this when replacing network hardware.

Thanks to all for your ideas. You helped me to eliminate possibilities.

So, my comment in post 7 was the culprit?