WiFi.begin not connecting
Posted: Thu May 05, 2016 10:50 am
I was super excited when my Arduino IDE (v1.6.5) was able to make pin 16 on my development ESP8266 board blink, but I have been super frustrated that the WiFi.begin hasn't worked for two+ hours. Note, this board was able to connect just fine via .lua script a couple of days ago. I upgraded to Arduino v1.6.8 and am using Generic 8266 board.
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());
}
}
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());
}
}