ModelessConnect.ino 1.5 KB

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