diff --git a/http_grab.ino b/http_grab.ino index c808200..163cf4a 100755 --- a/http_grab.ino +++ b/http_grab.ino @@ -14,7 +14,7 @@ String getHTML(String url) { if(httpCode > 0) { // HTTP header has been send and Server response header has been handled - Serial.printf("[HTTP] GET: %d\n", httpCode); + Serial.printf("[HTTP] GET %d: %s\n", httpCode, url.c_str()); // file found at server if(httpCode == HTTP_CODE_OK) { diff --git a/wifi.ino b/wifi.ino index fe89f14..8760351 100755 --- a/wifi.ino +++ b/wifi.ino @@ -4,12 +4,20 @@ void connectWiFi() { // connect to the wifi with the above defined credentials if(WiFi.status() == WL_CONNECTED) { return; } // return if not connected - Serial.println("[WiFi] Connecting to WiFi..."); + Serial.print("[WiFi] Connecting to WiFi..."); WiFi.begin(wiFiSSID, wiFiPSK); - delay(10000); // pause the program 5 secs to give time for connection - if(WiFi.status() != WL_CONNECTED) { Serial.printf("[WiFi] Failed connecting to WiFi \"%s\".", wiFiSSID); return; } - Serial.printf("[WiFi] Connected to WiFi \"%s\", got IP-Adress ", wiFiSSID); + while(WiFi.status() != WL_CONNECTED) { + delay(2000); Serial.printf("."); + if(WiFi.status() == WL_NO_SSID_AVAIL) { + Serial.println("[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL"); + return; + } else if(WiFi.status() == WL_CONNECT_FAILED) { + Serial.println("[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED"); + return; + } + } + Serial.printf("\n[WiFi] Connected to WiFi \"%s\", got IP-Adress ", wiFiSSID); Serial.println(WiFi.localIP()); Serial.println("[NTP] Getting time...");