ESP8266-01 WiFi connect
Posted: Sun Dec 18, 2016 3:35 pm
Hi
I have a problem that I am hoping a 'sage' will be able to shed light on.
I have 2 hubs I need to be able to connect to one called 'Thomson19067C' and the other 'SKYOF526'
My code will connect to Thomson with no problem but I am unable to connect to sky, if anyone has any ideas maybe they can point me in the right direction
my code is:
thanks
Dave
I have a problem that I am hoping a 'sage' will be able to shed light on.
I have 2 hubs I need to be able to connect to one called 'Thomson19067C' and the other 'SKYOF526'
My code will connect to Thomson with no problem but I am unable to connect to sky, if anyone has any ideas maybe they can point me in the right direction
my code is:
Code: Select all
String ss1 = "Thomson19067C";
String ss2 = "SKYOF526";
String pw1 = "password1";
String pw2 = "password2";
byte wifiTrys=0;
void WifiConnect() {
char ssbuff[10]; char pwbuff[12];
ss1.toCharArray(ssbuff, ss1.length()+1);
pw1.toCharArray(pwbuff, pw1.length()+1);
WiFi.disconnect();
while(WiFi.status() != WL_CONNECTED){
wifiTrys=0;
Serial.print("Connecting To: "); Serial.println(String(ssbuff));
WiFi.begin(ssbuff, pwbuff);
while (WiFi.status() != WL_CONNECTED) {
Serial.print("."); delay(500);
wifiTrys++;
if(wifiTrys == 50) break;
}
Serial.println();
if(WiFi.status() != WL_CONNECTED) {
WiFi.disconnect();
if(String(ssbuff) == ss1) {
ss2.toCharArray(ssbuff, ss2.length()+1);
pw2.toCharArray(pwbuff, pw2.length()+1);
} else {
ss1.toCharArray(ssbuff, ss1.length()+1);
pw1.toCharArray(pwbuff, pw1.length()+1);
}
}
}
thanks
Dave