Here's what I am trying and it will not connect, even if I try an open WiFi network. Note the LED still blinks, but serial always reports IP is 0.0.0.0:
#include <ESP8266WiFi.h>
int p = 16;
const char ssid[] = "ssid";
const char pass[] = "password";
void setup() {
pinMode(p, OUTPUT);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
}
void loop() {
digitalWrite(p, HIGH);
delay(500);
digitalWrite(p, LOW);
delay(500);
if (Serial.available() > 0) {
while (Serial.available() > 0) Serial.read();
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin("ssid", "password");
Serial.println("");
int retries = 0;
while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
retries++;
delay(500);
Serial.println(".");
}
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
}