ModelessConnect.ino 1.4 KB

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