ESP32 wifi connect() priority when multiple APs with identical SSID are present (WiFi extenders)

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

ESP32 wifi connect() priority when multiple APs with identical SSID are present (WiFi extenders)

Postby zliudr » Wed Sep 25, 2024 9:38 pm

I have this really weird issue that if I have multiple APs sharing the same SSID and password to expand my WiFi coverage, then connect() will always prefer a certain AP even if the reception is horrible. I wonder if there is any default settings when multiple devices broadcast the same SSID, which to connect, if bssid is not given in connect().

Here is my set up. I have 3 APs, office (best rssi by scan() around -25), basement (worst rssi by scan() around -65), and phone (good rssi by scan() around -30).

So if all 3 are present and I issue connect() without BSSID, the board always seems to connect to my phone even though before and after connection scans show consistently that office AP is better than phone in reception. But if the phone AP is turned off, the connection is made to the basement AP, worst rssi by a large margin, always. Office AP with best reception by scan() isn't touched. Only if I also disconnect my basement AP, and the only one still on is office AP, the board connects to office AP.

So I wonder if a desired behavior of connecting to the SSID with the best rssi value can be specified for connection, so if multiple APs are present, the best one is used.

I use MicroPython 1.20 based on ESP-IDF 4.4 but it's based on ESP-IDF so I checked ESP-IDF reference on wifi initialization and connection, which I used to do a number of years ago but never dealt with multiple APs with same SSID:

https://docs.espressif.com/projects/esp ... _wifi.html

There isn't any mention of the scenario I mentioned (pick best rssi if multiple AP have the same SSID). The only other thing I can think of is maybe channel number.

So the order of preference of phone>basement>office is an ascending order of channel numbers 1,2,7. Maybe ESP32 scans one channel for desired SSID, if found, connect to it, if not, go to the next channel?

Here are my three APs:
(ssid, bssid, channel, RSSI, security, hidden)
[
(b'myap', b'\xd8\x07\xb6\xd8\xc0/', 7, -28, 3, False), # office
(b'myap', b'\xf6\xc1\x91\xc8\xd7_', 1, -32, 7, False), # phone
(b'myap', b'P\xd4\xf7l\x8f\xc4', 2, -66, 3, False) # basement
]

There is a vague mention of channel in ESP-IDF here:

https://docs.espressif.com/projects/esp ... t7channelE

The struct struct wifi_sta_config_t, which contains a channel element, is one of the init parameters.

So is it true that the connect() actually doesn't consider the multiple AP with the same SSID scenario and just scans channels from 1 to 13 upwards until the SSID is found without doing a extra step to find the AP with best RSSI?

I could explore MicroPython 1.23 that is based on ESP-IDF 5.0.4 but the references I provided are "latest" so maybe the IDF version won't matter to the answer.

Thanks for your time!

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: ESP32 wifi connect() priority when multiple APs with identical SSID are present (WiFi extenders)

Postby zliudr » Thu Sep 26, 2024 4:28 am

Also, is there any way to show bssid the ESP32 is connected to? Thanks.

Who is online

Users browsing this forum: davekrum, MicroController and 101 guests