Updated ESP reset intervak. Modified code formatting.

This commit is contained in:
Kai Lauterbach 2022-05-25 21:45:09 +02:00
parent 01108980dd
commit 7c935946ac
3 changed files with 12 additions and 7 deletions

View file

@ -10,7 +10,7 @@
#define DELAY_LOOP_MS 50 #define DELAY_LOOP_MS 50
#define POWERSAVING_SLEEP_S 600 #define POWERSAVING_SLEEP_S 600
#define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover #define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover
#define RESET_ESP_TIME_INTERVAL_MS 1200000 // (60*60*6*1000) // reset every 6 hours #define RESET_ESP_TIME_INTERVAL_MS (60*60*6*1000) // (60*60*6*1000) // reset every 6 hours
#define WIND_SENSOR_MEAS_TIME_S 15 #define WIND_SENSOR_MEAS_TIME_S 15
#define INITIAL_WEBSERVER_TIME 20 #define INITIAL_WEBSERVER_TIME 20

View file

@ -186,7 +186,7 @@ void loop()
// call sub loop function // call sub loop function
_loop(); _loop();
//Needed to give WIFI time to function properly // Needed to give WIFI time to function properly
delay(DELAY_LOOP_MS); delay(DELAY_LOOP_MS);
update_sensor_cnt++; update_sensor_cnt++;
@ -200,7 +200,8 @@ void loop()
#endif #endif
} }
void _loop() { void _loop()
{
#ifdef WEBUPDATER_FEATURE #ifdef WEBUPDATER_FEATURE
if (UPDATE_WEBSERVER_INTVERVAL_S * 1000 / DELAY_LOOP_MS <= update_webserver_cnt) if (UPDATE_WEBSERVER_INTVERVAL_S * 1000 / DELAY_LOOP_MS <= update_webserver_cnt)
@ -253,7 +254,7 @@ void _loop() {
#endif #endif
#ifdef RESET_ESP_TIME_INTERVAL #ifdef RESET_ESP_TIME_INTERVAL
// if millis() reached interval (1h) restart ESP // if millis() reached interval restart ESP
if (RESET_ESP_TIME_INTERVAL_MS <= millis()) if (RESET_ESP_TIME_INTERVAL_MS <= millis())
{ {
debug("Resetting firmware intentionally"); debug("Resetting firmware intentionally");
@ -263,7 +264,8 @@ void _loop() {
#endif #endif
#ifndef BATTERY_POWERED #ifndef BATTERY_POWERED
if (UPDATE_SENSOR_INTERVAL_S * 1000 / DELAY_LOOP_MS > update_sensor_cnt) { if (UPDATE_SENSOR_INTERVAL_S * 1000 / DELAY_LOOP_MS > update_sensor_cnt)
{
return; return;
} }
#endif #endif
@ -278,7 +280,8 @@ void _loop() {
#endif #endif
update_sensor_cnt = 0; update_sensor_cnt = 0;
for (uint8_t i = 0; i < VALUES; i++) { for (uint8_t i = 0; i < VALUES; i++)
{
if (sensors[i]) { if (sensors[i]) {
currentSensorData[i] = sensors[i](); currentSensorData[i] = sensors[i]();
} else { } else {
@ -302,7 +305,8 @@ void _loop() {
} }
void logToSerial(float sensorValues[]) { void logToSerial(float sensorValues[])
{
Serial.println(""); Serial.println("");
Serial.println("Current readings:"); Serial.println("Current readings:");
Serial.println("Temperature: " + String(sensorValues[SENSOR_TEMPERATURE]) + " °C"); Serial.println("Temperature: " + String(sensorValues[SENSOR_TEMPERATURE]) + " °C");

View file

@ -80,6 +80,7 @@ void showHTMLMain(void)
"<tr><td>windspeed</td><td>" + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + "</td></tr>" "<tr><td>windspeed</td><td>" + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + "</td></tr>"
"<tr><td>pressure</td><td>" + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + "</td></tr>" "<tr><td>pressure</td><td>" + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + "</td></tr>"
"<tr><td>batvoltage</td><td>" + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + "</td></tr>" "<tr><td>batvoltage</td><td>" + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + "</td></tr>"
"<tr><td>millis</td><td>" + String(millis()) + "</td></tr>"
"</table>" "</table>"
"</body></html>"; "</body></html>";