Advertisement
Guest User

Autoconnect Wifimanager

a guest
Feb 1st, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
  2.  
  3. //needed for library
  4. #include <DNSServer.h>
  5. #include <ESP8266WebServer.h>
  6. #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
  7.  
  8.  
  9. void setup() {
  10. // put your setup code here, to run once:
  11. Serial.begin(115200);
  12.  
  13. //WiFiManager
  14. //Local intialization. Once its business is done, there is no need to keep it around
  15. WiFiManager wifiManager;
  16. //reset saved settings
  17. //wifiManager.resetSettings();
  18.  
  19. //set custom ip for portal
  20. //wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
  21.  
  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.  
  30.  
  31. //if you get here you have connected to the WiFi
  32. Serial.println("connected...yeey :)");
  33. }
  34.  
  35. void loop() {
  36. // put your main code here, to run repeatedly:
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement