Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By mikekgr
#72542
rudy wrote:What exactly have you done so far? Have you tried anything with the multi example I suggested? Show what you have and then you might get some help. Please explain why I should spend a couple of hours to give you the help without you showing that you have made any effort on your own.


Please explain why I should spend a couple of hours to give you the help without you showing that you have made any effort on your own


Actually you have not! I asked for help, I did not force you to help me...

OK, I solve my problem using three simple steps ( although I did not cover all my "requirements" ):
1) I trying to be connected using my default ssid and password as these are specified at the sketch
2) If the connection is not done in a specific time-frame ( 10 secinds ) then I go to step ( 3 )
3) I activate wifimanager that for sure it first trying to get connected using the last know ssid password, if not connected then it starts esp8266 in Station mode so using my mobile or pc devices I can give the desired ssid and password through wifimanager web interface.

That's it what I have done!
User avatar
By rudy
#72554 Those are general statements. They say what you think you have done. (and probably have) You ask for help but you don't post your code. So how is anyone supposed to help you?
User avatar
By mikekgr
#72555
rudy wrote:Those are general statements. They say what you think you have done. (and probably have) You ask for help but you don't post your code. So how is anyone supposed to help you?


Nothing very sophisticate to show... the related code snippets are:

Code: Select allconst char* ssid     = "TestAP";
const char* password = "12345678";

/// ===> START OF SETUP <=== ///
void setup() {
   if (!StartWiFi(ssid,password)) {
     Serial.println("Failed to start WiFi Service after 20 attempts");;
    }
   WiFiManager wifiManager;
   wifiManager.autoConnect("MYSSID", "12345678");
///  wifiManager.setConfigPortalTimeout(360); /// Configuration Portal Timeout
   wifiManager.setTimeout(60); /// reset ESP8266 if the timeout occured, that means ex 60 seconds without wifimanager portals connection.
                              /// timeout does not occured inside the wifimanager portal ///
}

int StartWiFi(const char* ssid, const char* password){
  int connAttempts = 0;
  Serial.println("\r\nConnecting to: "+String(ssid));
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED ) {
    delay(200);
    Serial.print(".");
    if(connAttempts > 50) return false;
    connAttempts++;
  }
  Serial.print("WiFi connected\r\nIP address: ");
  Serial.println(WiFi.localIP());
  re```turn true;
}