I have an Arduino Nano 33 IoT configured to connect to my WiFi network with a pretty straightforward code:

#include <WiFiNINA.h>

int status = WL_IDLE_STATUS;
status = WiFi.status();
while (status != WL_CONNECTED) {
    status = WiFi.begin(ssid, pass);
    if (status == WL_CONNECTED) break;

My problem is that in an environment with multiple access points sharing the same SSID (roaming environment) my Arduino is constantly connecting to the weakest one of the access points.

I verified with WiFi Explorer on my laptop that multiple access points are in reach at the same location where the Arduino is placed and for some reason my Arduino decides to connect to the base station with BSSD ending :CA:81, which is paradoxly the weakest one:

WiFi explorer

Is there a way to address this issue?

  • From you're list you'd only get the choice of the first two as the NINA is a b/g/n only module I think. But not sure why it's not connecting to :58:E2 if it has the same SSID.
    – Dan
    Commented Jul 26, 2022 at 9:03
  • 1
    What happens when you set the second accesspoint in the list to channel 11?
    – ocrdu
    Commented Jul 26, 2022 at 9:14
  • @ocrdu Unfortunately changing channel to 11 and resetting the Arduino did not help :( Commented Jul 26, 2022 at 11:35
  • @DanSheppard Yes, exactly. Commented Jul 26, 2022 at 11:35

1 Answer 1


On Nano 33 IoT the WiFi network adapter is NINA esp32 module with Arduino's nina-fw. nina-fw is written with the use of ESP-IDF framework by the esp32 manufacturer Espressif.

To connect to an AP the ESP-IDF has a configuration function, which takes a structure with settings. One of the settings is wifi_scan_method and nina-fw uses WIFI_FAST_SCAN. The alternative is WIFI_ALL_CHANNEL_SCAN.

WIFI_FAST_SCAN Do fast scan, scan will end after find SSID match AP

There is no simple solution for this. I don't know why they changed the setting. If it should be configurable then the firmware and the WiFiNINA library have to change to support it.

Or you can get the sources of the firmware, change the setting, build the firmware (it is not trivial) and flash it to NINA on your Nano.

  • This is a VERY good clue, but I think we should complete this answer with a working code. According to the changelog (github.com/arduino/nina-fw/blob/master/CHANGELOG), the WiFiNINA library has changed the default behaviour from WIFI_ALL_CHANNEL_SCAN to WIFI_FAST_SCAN between versions v1.2.1 and v1.2.2 in 2018. They also added a setScanMethod in v2.0.0 (in 2021), sadly, this version is not yet available in the Arduino package manager. I can't really find an Arduino specific documentation for calling esp_wifi_set_config based on your answer. I guess I can downgrade to 1.2.0... Commented Jul 26, 2022 at 11:55
  • @adamsfamily, setScanMethod was added in esp32 Arduino WiFi library which has nothing do do with Nano 33 IoT
    – Juraj
    Commented Jul 26, 2022 at 14:15
  • All right but how to configure WIFI_ALL_CHANNEL_SCAN with the Arduino library? I'm not able to call the esp_wifi_set_config as the Arduino IDE complains that the function does not exist :( Should I fork the Arduino WiFiNINA library and hardcode complete scan? I am very surprised that this is the default behaviour because connecting to the strongest base stations is key in a WiFi environments, especially in IoT. I'm surprised that no one else has the same problem? Commented Jul 28, 2022 at 6:39
  • @adamsfamily the esp_wifi_set_config is used in firmware running in the NINA module, not in the WiFiNINA library which is used in the main SAMD MCU
    – Juraj
    Commented Jul 28, 2022 at 8:11
  • 1
    Thanks, I accepted the answer. I'll try to report this towards the Arduino development team because I think this is really essential. Commented Jul 29, 2022 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.