AutoConnect.ino 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. void setup() {
  12. // put your setup code here, to run once:
  13. Serial.begin(115200);
  14. //WiFiManager
  15. //Local intialization. Once its business is done, there is no need to keep it around
  16. AsyncWiFiManager wifiManager(&server,&dns);
  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. //if you get here you have connected to the WiFi
  29. Serial.println("connected...yeey :)");
  30. }
  31. void loop() {
  32. // put your main code here, to run repeatedly:
  33. }