AutoConnect.ino 1.2 KB

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