-->
Page 1 of 3

ESP8266-01 WiFi connect

PostPosted: Sun Dec 18, 2016 3:35 pm
by Hoka
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:
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

Re: ESP8266-01 WiFi connect

PostPosted: Mon Dec 19, 2016 6:31 am
by AcmeUK
Your second block of code is different to the first block. What happens if you try to connect the SKY hub first?

Re: ESP8266-01 WiFi connect

PostPosted: Mon Dec 19, 2016 7:55 am
by Hoka
@acmeUK
hi thanks for your interest
I've tried several things:
1) swapping the order so that Sky is first in the list with the same result, no connection
2) taking out the Thomson side altogether so that it is only trying to connect to Sky- still no connection
3) tried logging in to Sky with a laptop with same credentials, this works with no problem, laptop always connects
I did read somewhere that the 8266 retains log in details and will not connect to a different network while the retained details are still in memory. This was when I added the WiFi.disconnect() but the result is the same still no connection, it has had me running around in circles for about a week.
I am using firmware v1.4.0_15_09_18 and did wonder if updating might help but have not tried it
cheers
dave

Re: ESP8266-01 WiFi connect

PostPosted: Mon Dec 19, 2016 8:12 am
by eduperez
Isn't "ssbuf" a bit to small to store "Thomson19067C"? Anyway, did you try to simplify that code, and just make a simple connection to "SKY" using the bare minimum code needed?