ESP32 could not associate with my AP in event site.
Posted: Sat Mar 05, 2022 6:08 am
Hello all,
Could any one tell the reason why ESP32 could not associate with my WiFi AP in the event site?
I want to know the limitation of the number of APs that ESP32 can scan to find the specific SSID.
When I took my device using ESP32 as a main processer to an event site where there are enormous number of WiFi routers(Access Point)(maybe more than 100 APs around my device including with my AP), my device could not get IP address from DHCP server running in my AP.
I downloaded the following code through Arduino IDE in order to check if ESP32 could find AP.
In most case, WiFi.scanNetworks() returned "4 - 15", but following "WiFi.SSID" does not return my AP's ssid.
When ESP32 found my AP's ssid, WiFi.status returned "WL_CONNECTED WL_DISCONNECTED" or "WL_NO_SSID_AVAIL" and
never returned to "WL_CONNECTED".
After the event ended (that's means many AP's power were OFF), the ESP32 could reach my AP and get IP Address.
Does any one know why ESP32 could not access my AP ?
Is there any reason why WiFi.scanNetworks() returns only small bumber?
Bast regards.
Could any one tell the reason why ESP32 could not associate with my WiFi AP in the event site?
I want to know the limitation of the number of APs that ESP32 can scan to find the specific SSID.
When I took my device using ESP32 as a main processer to an event site where there are enormous number of WiFi routers(Access Point)(maybe more than 100 APs around my device including with my AP), my device could not get IP address from DHCP server running in my AP.
I downloaded the following code through Arduino IDE in order to check if ESP32 could find AP.
In most case, WiFi.scanNetworks() returned "4 - 15", but following "WiFi.SSID" does not return my AP's ssid.
When ESP32 found my AP's ssid, WiFi.status returned "WL_CONNECTED WL_DISCONNECTED" or "WL_NO_SSID_AVAIL" and
never returned to "WL_CONNECTED".
After the event ended (that's means many AP's power were OFF), the ESP32 could reach my AP and get IP Address.
Does any one know why ESP32 could not access my AP ?
Is there any reason why WiFi.scanNetworks() returns only small bumber?
- #include "WiFi.h"
- const char *ssid = "ssidofap";
- const char *pass = "password";
- void mydelay(int msec)
- {
- vTaskDelay(msec / portTICK_RATE_MS);
- }
- void wifi_connection(void)
- {
- do{
- if(WiFi.status() == WL_CONNECTED)
- break;
- mydelay(100);
- WiFi.disconnect();
- mydelay(100);
- WiFi.begin(ssid, pass);
- Serial.println("");
- for(int i=0;i<120;i++){
- mydelay(500);
- Serial.print(".");
- Serial.print(i);
- Serial.print(".");
- int wifist = WiFi.status() ;
- switch(wifist){
- case WL_IDLE_STATUS : Serial.println("WL_IDLE_STATUS");break;
- case WL_NO_SSID_AVAIL : Serial.println("WL_NO_SSID_AVAIL");break;
- case WL_SCAN_COMPLETED : Serial.println("WL_SCAN_COMPLETED");break;
- case WL_CONNECTED : Serial.println("WL_CONNECTED");break;
- case WL_CONNECT_FAILED : Serial.println("WL_CONNECT_FAILED");break;
- case WL_CONNECTION_LOST : Serial.println("WL_CONNECTION_LOST");break;
- case WL_DISCONNECTED : Serial.println("WL_DISCONNECTED");break;
- }
- if(WiFi.status() == WL_NO_SSID_AVAIL) {
- Serial.println("WL_NO_SSID_AVAIL, reconnection begins");
- mydelay(500);
- // break;
- }
- if(WiFi.status() == WL_CONNECTED){
- Serial.println("WL_CONNECTED");
- break;
- }
- }
- }while(WiFi.status() != WL_CONNECTED);
- if(WiFi.status() == WL_CONNECTED) {
- Serial.println("");
- Serial.print("Connected to ");
- Serial.println(ssid);
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- return ;
- }
- mydelay(500);
- }
- void setup()
- {
- Serial.begin(115200);
- WiFi.mode(WIFI_STA);
- WiFi.disconnect();
- delay(100);
- Serial.println("Setup done");
- }
- void loop()
- {
- Serial.println("scan start");
- int n = WiFi.scanNetworks();
- Serial.println("scan done");
- if (n == 0) {
- Serial.println("no networks found");
- } else {
- Serial.print(n);
- Serial.println(" networks found");
- for (int i = 0; i < n; ++i) {
- Serial.print(i + 1);
- Serial.print(": ");
- Serial.print(WiFi.SSID(i));
- Serial.print(": ");
- if(WiFi.SSID(i)==ssid)
- wifi_connection();
- Serial.print(": ");
- Serial.print(" (");
- Serial.print(WiFi.RSSI(i));
- Serial.print(")");
- Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
- delay(10);
- }
- }
- Serial.println("");
- delay(500);
- }
Bast regards.