Last active
January 24, 2019 19:20
-
-
Save rodvan/e55a869d45f8c624a794e09b81ab92a5 to your computer and use it in GitHub Desktop.
Revisions
-
rodvan renamed this gist
Jan 24, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rodvan created this gist
Jan 24, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ #include <ESP8266WiFi.h> #include <WiFiUdp.h> void setup() { int cnt = 0; WiFi.mode(WIFI_STA); Serial.begin(9600); pinMode(0, INPUT_PULLUP); Serial.println("2 sec before clear SmartConfig"); delay(2000); int isSmartConfig = digitalRead(0); if (isSmartConfig==0) { Serial.println("clear config"); WiFi.disconnect(); } // if wifi cannot connect start smartconfig while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); if(cnt++ >= 15){ WiFi.beginSmartConfig(); while(1){ delay(500); if(WiFi.smartConfigDone()){ Serial.println("SmartConfig Success"); break; } } } } Serial.println(""); WiFi.printDiag(Serial); // Print the IP address Serial.println(WiFi.localIP()); Serial.println(WiFi.macAddress()); } void loop() { }