AutoConnect.ino 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. 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. AsyncWiFiManager wifiManager(&server,&dns);
  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. //if you get here you have connected to the WiFi
  31. Serial.println("connected...yeey :)");
  32. }
  33. void loop() {
  34. // put your main code here, to run repeatedly:
  35. }