Current your code wakes up from sleep mode every hour.
Even if information is not displayed due to various errors, it wakes up from sleep mode every hour.
So what about code that goes into sleep mode for only 2-3 minutes when an error occurs?
I think it's better to wait 2-3 minutes and try to reboot than to see a Wi-Fi connection error message for an hour
// START WIFI
int wifiRSSI = 0;
wl_status_t wifiStatus = startWiFi(wifiRSSI);
if (wifiStatus != WL_CONNECTED)
{
killWiFi();
initDisplay();
if (wifiStatus == WL_NO_SSID_AVAIL)
{
Serial.println("SSID Not Available");
do
{
drawError(wifi_x_196x196, "SSID Not Available", "");
} while (display.nextPage());
}
else
{
Serial.println("WiFi Connection Failed");
do
{
drawError(wifi_x_196x196, "WiFi Connection", "Failed");
} while (display.nextPage());
}
display.powerOff();
*esp_sleep_enable_timer_wakeup(180 1000000ULL);
esp_deep_sleep_start();**
}
// FETCH TIME
bool timeConfigured = false;
timeConfigured = setupTime(&timeInfo);
if (!timeConfigured)
{ // Failed To Fetch The Time
Serial.println("Failed To Fetch The Time");
killWiFi();
initDisplay();
do
{
drawError(wi_time_4_196x196, "Failed To Fetch", "The Time");
} while (display.nextPage());
display.powerOff();
Current your code wakes up from sleep mode every hour. Even if information is not displayed due to various errors, it wakes up from sleep mode every hour. So what about code that goes into sleep mode for only 2-3 minutes when an error occurs? I think it's better to wait 2-3 minutes and try to reboot than to see a Wi-Fi connection error message for an hour
// START WIFI int wifiRSSI = 0; wl_status_t wifiStatus = startWiFi(wifiRSSI); if (wifiStatus != WL_CONNECTED) { killWiFi(); initDisplay(); if (wifiStatus == WL_NO_SSID_AVAIL) { Serial.println("SSID Not Available"); do { drawError(wifi_x_196x196, "SSID Not Available", ""); } while (display.nextPage()); } else { Serial.println("WiFi Connection Failed"); do { drawError(wifi_x_196x196, "WiFi Connection", "Failed"); } while (display.nextPage()); } display.powerOff(); *esp_sleep_enable_timer_wakeup(180 1000000ULL); esp_deep_sleep_start();**
}
// FETCH TIME bool timeConfigured = false; timeConfigured = setupTime(&timeInfo); if (!timeConfigured) { // Failed To Fetch The Time Serial.println("Failed To Fetch The Time"); killWiFi(); initDisplay(); do { drawError(wi_time_4_196x196, "Failed To Fetch", "The Time"); } while (display.nextPage()); display.powerOff();
} String refreshTimeStr; getRefreshTimeStr(refreshTimeStr, timeConfigured, &timeInfo);
// MAKE API REQUESTS int rxOWM[2] = {}; WiFiClient client; rxOWM[0] = getOWMonecall(client, owm_onecall); if (rxOWM[0] != HTTP_CODE_OK) { statusStr = "One Call " + OWM_ONECALL_VERSION + " API"; tmpStr = String(rxOWM[0], DEC) + ": " + getHttpResponsePhrase(rxOWM[0]); killWiFi(); initDisplay(); do { drawError(wi_cloud_down_196x196, statusStr, tmpStr); } while (display.nextPage()); display.powerOff();
} rxOWM[1] = getOWMairpollution(client, owm_air_pollution); killWiFi(); // wifi no longer needed if (rxOWM[1] != HTTP_CODE_OK) { statusStr = "Air Pollution API"; tmpStr = String(rxOWM[1], DEC) + ": " + getHttpResponsePhrase(rxOWM[1]); initDisplay(); do { drawError(wi_cloud_down_196x196, statusStr, tmpStr); } while (display.nextPage()); display.powerOff();
}