fingy

MultiWifi

Jan 19th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. #include <ESP8266WiFi.h>
  3. #include <ESP8266WiFiMulti.h>
  4.  
  5.  
  6. ESP8266WiFiMulti wifiMulti;
  7.  
  8. void setup() {
  9. // put your setup code here, to run once:
  10. Serial.begin(115200);
  11.  
  12. WiFi.mode(WIFI_STA);
  13. wifiMulti.addAP("xxx", "xxx");
  14. wifiMulti.addAP("xxx", "xxx");
  15. // wifiMulti.addAP("xxx", "xxx");
  16.  
  17. Serial.println("Connecting Wifi...");
  18. if (wifiMulti.run() == WL_CONNECTED) {
  19. Serial.println("");
  20. Serial.println("WiFi connected");
  21. Serial.println("IP address: ");
  22. Serial.println(WiFi.localIP());
  23. }
  24. }
  25.  
  26. void loop() {
  27. // put your main code here, to run repeatedly:
  28. if (wifiMulti.run() != WL_CONNECTED) {
  29. Serial.println("WiFi not connected!");
  30. delay(1000);
  31. }
  32. }
Add Comment
Please, Sign In to add comment