-->
Page 1 of 2

WiFi.begin not connecting

PostPosted: Thu May 05, 2016 10:50 am
by ChrisVA
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());
}

}

Re: WiFi.begin not connecting

PostPosted: Thu May 05, 2016 12:05 pm
by martinayotte
Your WiFi.begin() is inside your Serial.available(), so pretty normal that it never tried connecting since it didn't received any characters on serial ... :ugeek:

Re: WiFi.begin not connecting

PostPosted: Thu May 05, 2016 2:18 pm
by ChrisVA
I put it inside there so that I could re-try the connection. If I type something like "G" and hit send, it runs the .begin()

:(

Re: WiFi.begin not connecting

PostPosted: Fri May 06, 2016 6:40 am
by ChrisVA
I just re-flashed the board with NodeMCU and it works great connecting to WiFi with Lua. I am running a simple webserver .lua and I can control the onboard LEDs. :?