Advertisement
safwan092

Untitled

Dec 31st, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
  2.  
  3. void setup() {
  4. Serial.begin(9600);
  5. Connect_To_WiFi();
  6. // put your setup code here, to run once: ↓
  7.  
  8. }
  9.  
  10. void loop() {
  11. ReConnect_To_WiFi();
  12. // put your main code here, to run repeatedly: ↓
  13.  
  14. }
  15.  
  16.  
  17.  
  18. void ReConnect_To_WiFi() {
  19. while (WiFi.status() != WL_CONNECTED) {
  20. //delay(500);
  21. Serial.print(".");
  22. Connect_To_WiFi();
  23. }
  24. }
  25.  
  26. void Connect_To_WiFi() {
  27. WiFiManager wm;
  28. bool res;
  29. res = wm.autoConnect("Senior Project [Setup WiFi]"); // password protected ap
  30.  
  31. if (!res) {
  32. Serial.println("Failed to Connect!!");
  33. // ESP.restart();
  34. }
  35. else {
  36. //if you get here you have connected to the WiFi
  37. Serial.println("Connected...");
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement