I have an issue with WiFi.begin()
in esp8266-12F.
I'm going to connect the ESP8266 with the specific Access Point in the loop()
not in the setup()
.
I want if a specific AP is available, ESP8266 would connect to it.
In the below code, I supposed to connect to the "abc" AP and turns on an LED and if there is no connection, it turns the LED off, but WiFi.begin("abc", "123456789");
is not working.
What I have to do in this case?
setup(){
}
loop(){
if (WiFi.status() != WL_CONNECTED){
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin("abc", "123456789");
digitalWrite(5, HIGH);
} else {
digitalWrite(5, LOW);
}
}