Hardware: ESP-12
Core Version: 2.3.0
No WiFi connect since 2.3.0 if "delay >= 1000" in setup() for init of external hardware.
After upgrading to 2.3.0 many sketches wont connect anymore to WiFi Accesspoint.
Testing a few things showed up that the problem was caused by adding a delay(1000) in setup before WiFi.begin().
This was done to power up external hardware properly before starting the Arduino/ESP Code and connecting the WiFi.
After downgrading to 2.2.0 everything works fine again using this delay.
Module: Wemos D1 R2 & mini
Flash Size: 4MB/3MB
CPU Frequency: 80Mhz
char ssid[50] = "your ssid";
char password[50] = "your pwd";
void setup() {
Serial.begin(9600);
delay(1000); // for ext. hardware init <<<<<<<<<<<
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
delay(1000);
Serial.println("X");
}
i had that problem too !!! The Problem is not the delay().....
FIX FOR USING 2.3.0 CORE (only .begin if not connected)!!!!!!!
if (WiFi.status() != WL_CONNECTED) { // FIX FOR USING 2.3.0 CORE (only .begin if not connected)
WiFi.begin(ssid, password); // connect to the network
}
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
see:
(https://github.com/esp8266/Arduino/issues/2186)
and:
(https://github.com/esp8266/Arduino/issues/2594)
Hi there,
youre right, after adding a WiFi.mode(WIFI_OFF) at the beginning of setup() and enable it just directly before WiFi.begin() after all other stuff is done and a few delays later averything works fine again :)
Thanks for pointing to the other issues !!
Got the same problem but none of the workarounds seems to fix it.
I do quite some heavy init stuff (> 1sec) and put WiFi.mode(WIFI_OFF); at the beginning of setup.
After my >1sec seconds I do this
WiFi.mode(WIFI_STA);
listNetworks(0);
if (WiFi.status() != WL_CONNECTED) { // FIX FOR USING 2.3.0 CORE (only .begin if not connected)
WiFi.begin(ssid, password); // connect to the network
}
Still sometimes I got no networks found and after that no connection ..
....wifi evt: 1
STA disconnect: 201
....wifi evt: 1
STA disconnect: 201
.....wifi evt: 1
STA disconnect: 201
After a clean power cycle the whole thing is working, just after flashing or sometimes on power-cycling from battery it is not working.
Try using static IP rather than DHCP -- fixes it for me here. The internal DHCP seems to have issues under some conditions.
I just discovered this wonderful feature 馃槨. The workaround suggested in kendo55's post begs the question, "why is the module connected prior to WiFi.begin?". The workaround could be problematic if there is more than 1 AP and you need to connect to one specific one or change from one to the other.
I added a WiFi.disconnect() before WiFi.begin(). So far it has worked and I think it is a more robust solution.
Most helpful comment
i had that problem too !!! The Problem is not the
delay().....FIX FOR USING 2.3.0 CORE (only .begin if not connected)!!!!!!!
see:
(https://github.com/esp8266/Arduino/issues/2186)
and:
(https://github.com/esp8266/Arduino/issues/2594)