1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

add examples/WiFiMulti/WiFiMulti.ino

This commit is contained in:
Markus Sattler 2015-05-16 22:47:29 +02:00
parent 108a40acfd
commit 508f0802d5

View File

@ -0,0 +1,33 @@
/*
* This sketch trys to Connect to the best AP based on a given list
*
*/
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti WiFiMulti = ESP8266WiFiMulti();
void setup() {
Serial.begin(115200);
delay(10);
WiFiMulti.addAP("ssid_from_AP_1", "your_password_for_AP_1");
WiFiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2");
WiFiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");
Serial.println("Connecting Wifi...");
if(wifiMulti.run() == WL_CONNECTED) {
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
}
void loop() {
if(wifiMulti.run() != WL_CONNECTED) {
Serial.println("WiFi not connected!");
delay(1000);
}
}