lmarzen / esp32-weather-epd

A low-power E-Paper weather display powered by an ESP32 microcontroller. Utilizes the OpenWeatherMap API.
GNU General Public License v3.0
2.45k stars 194 forks source link

When unable to show e paper screen due to various errors #122

Open PaekHyun opened 3 weeks ago

PaekHyun commented 3 weeks ago

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();

**esp_sleep_enable_timer_wakeup(180 * 1000000ULL);
esp_deep_sleep_start();**

} 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();

**esp_sleep_enable_timer_wakeup(180 * 1000000ULL);
esp_deep_sleep_start();**

} 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();

**esp_sleep_enable_timer_wakeup(180 * 1000000ULL);
esp_deep_sleep_start();**

}

Asdf1qaz commented 2 weeks ago

This could kill the battery pretty fast though if your not with it