ESP8266 does not reconnect to WiFi on reboot The ESP8266 is supposed to remember the WiFi credentials and reconnect to the network (if it is available) after each reboot.  That was the topic of this question: Does the ESP8266 somehow remember wifi access data?

I was observing that behavior and something has changed, I think when I updated via Board Manager in the Arduino IDE.  Now the credentials are lost each time that the device reboots. I've tried going back to earlier versions, but I have not been able to roll back to a version of the board definition that restores the old behavior.

Here's a sample sketch that I boiled down for testing:

#include &lt;ESP8266WiFi.h&gt;

char ssid[] = "ssid";
char pss[]  = "pass";

void setup() {
  Serial.begin(115200);

  Serial.println("Started");

  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Not connected");
    WiFi.begin(ssid, pss);
    digitalWrite(0, LOW);
    digitalWrite(2, HIGH);
  } else {
    Serial.println("Connected");
    digitalWrite(0, HIGH);
    digitalWrite(2, LOW);
  }
}

void loop() {
  Serial.println("Loop");
  delay(500);
}


The first time through, of course, it hits the first case and prints "Not connected."  On reboot, however, I was expecting it to hit the second case and print "Connected".

I'm programming via the Arduino IDE.  The board is the Adafruit Feather HUZZAH ESP8266.  I've tried lwIP v1.4 and lwIP v2 in version 2.4.1 of the board.  I started rolling back versions from there got the same run-time results.

So, questions:


Is this a known bug of the ESP8266 modules in recent versions?
Is there some aspect of the WiFi configuration that's preserved on the board when I upload a new sketch? If so, how do I roll back?
The esp8266 SDK libraries starts the STA connection, but it is handled by other thread then the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Not connected");
    WiFi.begin(ssid, pss);
    digitalWrite(0, LOW);
    digitalWrite(2, HIGH);
  } else {
    Serial.println("Connected");
    digitalWrite(0, HIGH);
    digitalWrite(2, LOW);
  }


to connect with remembered STA mode, ssid and password, but with static IP address

  WiFi.setAutoConnect(false);
  IPAddress ip(192, 168, 1, 8);
  IPAddress gw(192, 168, 1, 1);
  IPAddress sn(255, 255, 255, 0);
  WiFi.config(ip, gw, sn, gw);
  WiFi.begin(); // uses remembered ssid and password
  WiFi.waitForConnectResult();