ModelessConnect.ino 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if defined(ESP8266)
  2. #include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
  3. #else
  4. #include <WiFi.h>
  5. #endif
  6. //needed for library
  7. #include <ESPAsyncWebServer.h>
  8. #include <ESPAsyncWiFiManager.h> //https://github.com/tzapu/WiFiManager
  9. AsyncWebServer server(80);
  10. DNSServer dns;
  11. AsyncWiFiManager wifiManager(&server,&dns);
  12. void setup() {
  13. // put your setup code here, to run once:
  14. Serial.begin(115200);
  15. //WiFiManager
  16. //Local intialization. Once its business is done, there is no need to keep it around
  17. //reset saved settings
  18. //wifiManager.resetSettings();
  19. //set custom ip for portal
  20. //wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
  21. //fetches ssid and pass from eeprom and tries to connect
  22. //if it does not connect it starts an access point with the specified name
  23. //here "AutoConnectAP"
  24. //and goes into a blocking loop awaiting configuration
  25. //wifiManager.autoConnect("AutoConnectAP");
  26. //or use this for auto generated name ESP + ChipID
  27. //wifiManager.autoConnect();
  28. wifiManager.startConfigPortalModeless("ModelessAP", "Password");
  29. server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
  30. request->send(200, "text/plain", "Hello World");
  31. });
  32. }
  33. void loop() {
  34. // put your main code here, to run repeatedly:
  35. wifiManager.loop();
  36. }