1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#include "FS.h" #include <ESP8266WiFi.h> #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> boolean init_esp = true; // set it "true" if you want to reset wifi configuration on every system startup void setup() { Serial.begin(115200); delay(10); if(init_esp) { SPIFFS.format(); WiFi.disconnect(); } WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(240); if (!wifiManager.autoConnect("freeelec.ir", "changeit")) { Serial.println(F("Failed to connect. Reset and try again...")); delay(3000); //reset and try again ESP.reset(); delay(5000); } //if you get here you have connected to the WiFi Serial.println(F("Connected to Wifi.")); Serial.print(F("My IP: ")); Serial.println(WiFi.localIP()); } void loop() { //add your code for loop() } |