#include #define WIFI_NETWORK "Network Name" #define WIFI_PASSWORD "Password" #define WIFI_TIMEOUT_MS 10000 void connectToWiFi(){ Serial.print("Connecting to WiFi"); WiFi.mode(WIFI_STA); WiFi.begin(WIFI_NETWORK, WIFI_PASSWORD); unsigned long startAttemptTime = millis(); while(WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < WIFI_TIMEOUT_MS){ Serial.print("."); delay(100); } if(WiFi.status() !=WL_CONNECTED){ Serial.println("Failed"); }else{ Serial.print("Connected"); Serial.println(WiFi.localIP()); } } // put your setup code here, to run once: void setup(){ Serial.begin(9600); connectToWiFi(); } void loop() { // put your main code here, to run repeatedly: }