mirror of
				https://github.com/0xFEEDC0DE64/arduino-esp32.git
				synced 2025-10-28 04:31:42 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			771 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			771 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  *  This sketch trys to Connect to the best AP based on a given list
 | |
|  *
 | |
|  */
 | |
| 
 | |
| #include <WiFi.h>
 | |
| #include <WiFiMulti.h>
 | |
| 
 | |
| WiFiMulti wifiMulti;
 | |
| 
 | |
| 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);
 | |
|     }
 | |
| } |