esp-idf: Wifi occasionally won't connect to dual-band router with same SSID (IDFGH-4064)

Environment

  • Development Kit: ESP32-Wrover-Kit (Hazzah Feather32)

  • Module or chip used: ESP32-WROOM-32

  • IDF version 2.0 (Platformio)

  • Build System: PlatformIO Core 5.0.1 Python 3.8.4-final.0 System Type darwin_x86_64 Platform macOS-10.15.7

  • platformio.ini [env:esp32dev] platform = espressif32 board = featheresp32 framework = arduino

  • Compiler version: xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0

  • Operating System: macOS

  • IDE: MS Code / Platformio 5.0.1

  • Power Supply: USB

Problem Description

I have a Synology AC2600 dual-band router advertising a single SSID on 2.4 and 5ghz. OCCASIONALLY (no firmware change), it will simply not connect to Wifi. MOST of the time, it does. When it fails, it is consistent and has the same behavior if I re-flash or even clear the flash. I have a web server running on the softAP that allows me to change the credentials.

I have a Pi that is in AP mode (2.4ghz) and it connects immediately to that. Switch back the creds to the dual-band and it won’t connect.

Flashed the same firmware to my Olimex ESP32-EVB and it connected fine. I believe, eventually, it would exhibit the same behavior. I reflashed the same firmware to the Feather32 and the behavior was the same – won’t connect to dual-band. Perhaps this is because the MAC’s are different.

So I decided to test this by watching the serial output and disabling my 5ghz advertisement and BAM, it immediately connects.

This is a SUBSTANTIAL issue because these instruments will be in the field connecting to a local AP that may be dual-band as well.

Expected Behavior

It should consistently connect to a dual-band wifi AP with a 2.4ghz station.

Actual Behavior

It OCCASIONALLY, repeatedly, won’t connect.

Steps to reproduce

I’ve seen posts about people solving this by turning off their 5ghz radio on their router as a solution, which is not a solution. Since it’s occasional, seems it might be triggered by distance from AP and how crowded the 2.4ghz channel is with other traffic – dunno.

Code to reproduce this issue

    WiFi.begin(ssidSTA, passwordSTA);
    WiFi.setAutoReconnect(true);

    while (WiFi.status() != WL_CONNECTED && ticks++ < 20) {
      WiFi.begin(ssidSTA, passwordSTA);
      vTaskDelay(pdMS_TO_TICKS(500UL));
    }

Debug Logs

Reading from EEPROM, ssidSTA is (Christopher), passwordSTA is (XXXXXX)
SoftAP (LRI_ESP_30:AE:A4:26:69:40) IP address is (192.168.4.1), AP MAC address is (30:AE:A4:26:69:41).  Web server listening on port 80
ESP Network name is (Box-0448), Box ID is (ESP_30:AE:A4:26:69:40)
Attempting to connect to Wifi Station (Christopher) with password (XXXXXX)
Successful getting local time: 2020-10-02 17:54:19
Connected to Wifi Station (Christopher), IP address: (192.168.1.184), our hostname is (Box-0448-v1000) and our public IP is (XXXXXXXXX)
SETUP COMPLETE.
Secure MQTT connected, subscribed to (LRI/All) and (LRI/ESP_30:AE:A4:26:69:40)

----------  If failing --------
Wifi is disconnected, status is (1), attempting reconnect
Attempting to connect to Wifi Station (Christopher) with password (XXXXXXXX)
...

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 39 (11 by maintainers)

Most upvoted comments

Hi,

Anyone find the Solution?