Description
Edit: It turns out this isn't to do with the core release its something to do with the SPIFFS option when doing the sketch upload. For most modules i try the static IP connect is slow unless uploaded with "Generic ESP8266 module" selected and the Flash size set to 512K (no SPIFFS).
With a NodeMCU V1 board it connects slow when uploaded with "NodeMCU 1.0 (ESP-12E Module)" selected but the board connects fast when the code is uploaded with "Generic ESP8266 Module" selected and 512K (no SPIFFS). Similar with a NodeMCU 0.9 board it connects slow when uploaded with "NodeMCU 0.9 (ESP-12 Module)" selected but connects fast uploaded with "Generic ESP8266 Module" selected and 512K (no SPIFFS).
----- old text:
Using the sketch included here on an ESP-12 and the staging release from the 9th of Nov it connects to the WiFi access point in about 170 milliseconds, and thats always consistent and reliably close to that 170ms time (plus or minus a few milliseconds).
With the same ESP-12 and same sketch (only change adding the c_str() on WiFi.SSID()) using the 2.0.0 release its much slower and consistently connects at about 1060 milliseconds (again plus or minus a few milliseconds) - thats six times slower!
Interestingly, not all the ESPs i try with that 9th of Nov staging code connect fast, a lot are the slow 1060 millisecond connect time with either code release. But the ESPs that do connect fast will only work fast with that 9th Nov code and always connect slow with the 2.0.0 release.
Also, the very first connect after power up is a bit slower so with the fast board/9thNov code the first connect takes about 2197 milliseconds and then subsequent connects after a deepSleep take 170ms. On the Slow ones its always about 3070ms for the first connect and 1060 ms for the subsequent ones after deepSleep.
Odd eh? Any ideas?
#include <ESP8266WiFi.h>
extern "C" {
#include "user_interface.h"
}
const unsigned long SLEEP_INFTERVAL = 15 * 1000 * 1000; // 15 sec
const char* ssid = "BTHub5-72W5";
const char* password = "xxxxxxxxxx";
long setupStartMillis;
void setup() {
setupStartMillis = millis();
Serial.begin(115200);
Serial.println();
Serial.print("Setup start millis: "); Serial.println(setupStartMillis);
Serial.print(", Mac: "); Serial.println(WiFi.macAddress());
WiFi.mode(WIFI_STA);
Serial.print("Connecting to: "); Serial.println(ssid);
if (strcmp (WiFi.SSID(),ssid) != 0) {
// if (strcmp (WiFi.SSID().c_str(),ssid) != 0) {
WiFi.begin(ssid, password);
} else {
// WiFi.begin();
}
WiFi.config(IPAddress(192,168,1,13), IPAddress(192,168,1,254), IPAddress(255,255,255,0));
int timeout = millis()+10000;
while ((WiFi.status() != WL_CONNECTED) && (timeout > millis())) {
delay(1);
}
if ((WiFi.status() != WL_CONNECTED)) {
Serial.println("WiFi FAILed to connect");
} else {
Serial.print("WiFi connected in: "); Serial.print(millis()-setupStartMillis);
Serial.print(", IP: "); Serial.print(WiFi.localIP());
Serial.print(", Mac: "); Serial.print(WiFi.macAddress());
Serial.println();
}
Serial.println("delay(10000)...");
delay(10000);
Serial.print("Deep sleep for ");
Serial.print(SLEEP_INFTERVAL / 1000000);
Serial.println(" secs...");
ESP.deepSleep(SLEEP_INFTERVAL);
// system_deep_sleep_set_option(0);
// system_deep_sleep(SLEEP_INFTERVAL);
// delay(1000); // needed as sleep seems to tak a little while to happen
}
void loop() {
// should never get here
}```