Added blinking led (pin number 2) when wifi connection failed
This commit is contained in:
parent
646aa9fce4
commit
2b56d05cb6
@ -18,6 +18,9 @@ const String ntpServer = "pool.ntp.org"; // address of ntp server; may also be
|
|||||||
const long gmtOffset_sec = 3600; // for localization (gmt = greenwich mean time); in germany: 3600
|
const long gmtOffset_sec = 3600; // for localization (gmt = greenwich mean time); in germany: 3600
|
||||||
const int daylightOffset_sec = 3600; // for daylight saving
|
const int daylightOffset_sec = 3600; // for daylight saving
|
||||||
|
|
||||||
|
// onboard LED
|
||||||
|
const int LED_ON_WIFI_ERROR = 2;
|
||||||
|
|
||||||
// style of the frame shown
|
// style of the frame shown
|
||||||
sFONT TITLE_FONT = Font20;
|
sFONT TITLE_FONT = Font20;
|
||||||
char TITLE_TEXT[] = "Losung heute";
|
char TITLE_TEXT[] = "Losung heute";
|
||||||
|
14
wifi.ino
14
wifi.ino
@ -1,6 +1,18 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
|
void blinkLED(int pin) {
|
||||||
|
pinMode(pin, OUTPUT);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(pin,HIGH);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(pin,LOW);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(pin,HIGH);
|
||||||
|
delay(500);
|
||||||
|
digitalWrite(pin,LOW);
|
||||||
|
}
|
||||||
|
|
||||||
bool connectWiFi() { // connect to the wifi with the above defined credentials
|
bool connectWiFi() { // connect to the wifi with the above defined credentials
|
||||||
if(WiFi.status() == WL_CONNECTED) { return true; } // return if not connected
|
if(WiFi.status() == WL_CONNECTED) { return true; } // return if not connected
|
||||||
|
|
||||||
@ -11,9 +23,11 @@ bool connectWiFi() { // connect to the wifi with the above defined credentials
|
|||||||
delay(2000); Serial.printf(".");
|
delay(2000); Serial.printf(".");
|
||||||
if(WiFi.status() == WL_NO_SSID_AVAIL) {
|
if(WiFi.status() == WL_NO_SSID_AVAIL) {
|
||||||
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL");
|
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL");
|
||||||
|
blinkLED(LED_ON_WIFI_ERROR);
|
||||||
return false;
|
return false;
|
||||||
} else if(WiFi.status() == WL_CONNECT_FAILED) {
|
} else if(WiFi.status() == WL_CONNECT_FAILED) {
|
||||||
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED");
|
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED");
|
||||||
|
blinkLED(LED_ON_WIFI_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user