**//Updates://** [[wifimanager|WiFiManager]] **//might be a better solution//**
WiFi Auto Configuration
* if SSID is not visible, have to manually connect to SSID: **WIFIConfig** with Password: **12345678**
lib_deps = drmpf/ESPAutoWiFiConfig @ ^2.2.0
#include
#include
#include
ESP8266WebServer server(80);
int ledPin = 2;
// use ledPin = 2 for NodeMCU / ESP-01S (Blue led on GPIO2)
// use ledPin = 1 for ESP-01 (Blue led on TX (GPIO1), ESP-01 also has a Red power led)
bool highForLedOn = false; // need to make output low to turn ESP8266, ESP-01, ESP-01S Led ON
size_t eepromOffset = 0; // if you use EEPROM.begin(size) in your code add the size here so AutoWiFi data is written after your data
// ========== trivial webserver example =============
void notFound() {
server.send(404, "text/plain", "Not found");
}
void handleRoot() {
server.send(200, "text/html", "Link: Firmware Update
");
}
void startWebServer() {
server.on("/", handleRoot);
server.onNotFound(notFound);
server.begin();
}
void initializewificonfig()
{
if (ESPAutoWiFiConfigSetup(ledPin, highForLedOn, eepromOffset))
{ // check if we should start access point to configure WiFi settings
return; // in config mode so skip rest of setup
}
startWebServer();
}