-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoConnect w/ ESP32 does not automatically join saved wireless network all the times #79
Comments
Where there are a lot of WiFi radio signals mixed, the sequence up to first WiFi.begin which not accompanied by SSID and password of the current AutoConnect may be insufficient. Can you do the following tests to pursue this issue? None of them use AutoConnect. It verifies the behavior of WiFi.begin in a crowded WiFi radio environment. #include <WiFi.h>
wl_status_t waitForConnect(unsigned long timeout) {
wl_status_t wifiStatus;
Serial.print("Connecting");
unsigned long st = millis();
while ((wifiStatus = WiFi.status()) != WL_CONNECTED) {
if (timeout) {
if (millis() - st > timeout)
break;
}
Serial.print('.');
delay(300);
}
Serial.printf("%s\nIP:%s CH(%d)\n", wifiStatus == WL_CONNECTED ? "established" : "timeout", WiFi.localIP().toString().c_str(), WiFi.channel());
return wifiStatus;
}
void setup(){
Serial.begin(115200);
Serial.println();
WiFi.softAPdisconnect(true);
WiFi.mode(WIFI_STA);
delay(100);
if (!WiFi.config(IPAddress(0U), IPAddress(0U), IPAddress(0U), IPAddress(0U), IPAddress(0U)))
Serial.println("WiFi config failed");
WiFi.begin();
waitForConnect(30000);
}
void loop() {
} The above code is an excerpt part of AutoConnect::begin for first WiFi.begin. Please try running the above code with
Thank you for your cooperation. |
Hi, sorry for the delay. I did the test you asked.
|
Thank you for your testing and the result reports. Here, I have one suggestion. void setup(){
Serial.begin(115200);
Serial.println();
WiFi.softAPdisconnect(true);
delay(1000); // <-- here, insert additional delay
WiFi.mode(WIFI_STA);
delay(100);
if (!WiFi.config(IPAddress(0U), IPAddress(0U), IPAddress(0U), IPAddress(0U), IPAddress(0U)))
Serial.println("WiFi config failed");
WiFi.begin();
waitForConnect(30000);
} However, there is no basis for this workaround. Even if it works well, I think it is not different from a magic spell. Another possibility is router DHCP. The router always assigns 192.168.188.50. This means suggests that the connection with the MAC address of ESP32 is completed, but ESP32 may not capture the lease time of DHCP correctly. I recommend assigning a fixed IP to identify the source of the problem. IPAddress local_IP(192, 168, 188, 50);
IPAddress gateway(192, 168, 188, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
void setup(){
Serial.begin(115200);
Serial.println();
WiFi.softAPdisconnect(true);
WiFi.mode(WIFI_STA);
delay(100);
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS))
Serial.println("WiFi config failed");
WiFi.begin();
waitForConnect(30000);
} Can you try the above? The second test report from you will provide what we should do next. I will carry out a little more investigation. |
Since there was no response even after one month passed, closed this issue. |
Using version 0.98 I am able to connect to a wireless network but after restarting the equipment, it does not join the network automatically all the times. From the logs/serial output I can get "networks found -2" or sometimes "-1". Then it creates the hotspot where I am able to join and force it to connect to the saved SSID. Using the same code (w/ minor changes) on a ESP8266 it automatically connects to the wireless network ALL the times.
ps: I am the one with dozens of networks available (probably more than 30 or 40 in my area).
The text was updated successfully, but these errors were encountered: