#include #include "time.h" bool connectWiFi() { // connect to the wifi with the above defined credentials if(WiFi.status() == WL_CONNECTED) { return true; } // return if not connected Serial.print("[WiFi] Connecting to WiFi..."); WiFi.begin(wiFiSSID, wiFiPSK); while(WiFi.status() != WL_CONNECTED) { delay(2000); Serial.printf("."); if(WiFi.status() == WL_NO_SSID_AVAIL) { Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL"); return false; } else if(WiFi.status() == WL_CONNECT_FAILED) { Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED"); return false; } } Serial.printf("\n[WiFi] Connected to WiFi \"%s\", got IP-Adress ", wiFiSSID); Serial.println(WiFi.localIP()); return true; }