From 676a67c3c0373978ca5433bee07279922456f2b1 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Mon, 16 May 2022 13:34:33 +0200 Subject: [PATCH] Fixed webserver update time and modified webstat website content. --- firmware/config.h | 4 ++-- firmware/webUpdater.ino | 33 +++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/firmware/config.h b/firmware/config.h index cae52d4..3f592b2 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -19,8 +19,8 @@ #define WIFI_AUTOCONNECT_TIMEOUT_S 120 #define WIFI_CONFIG_PORTAL_TIMEOUT_S 120 #define UPDATE_SENSOR_INTERVAL_S 300 -#define UPDATE_WEBSERVER_INTVERVAL_S 1 -#define DELAY_LOOP_MS 60 +#define UPDATE_WEBSERVER_INTVERVAL_S 1 // Do not change, bigger values will prevent using the webinterface +#define DELAY_LOOP_MS 50 #define POWERSAVING_SLEEP_S 600 #define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover #define ENERGY_SAVING_ITERATIONS 30 diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index f416c19..15f5cc1 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -83,16 +83,29 @@ void showHTMLMain(void) void hb_webstat_send(void) { - httpServer.send(200, "text/html", hb_ws_msg_start + - hb_ws_msg_temp + - String(_webUpdater_sensValues[SENSOR_TEMPERATURE], 2) + ", " + - hb_ws_msg_humi + - String(int(_webUpdater_sensValues[SENSOR_HUMIDITY]), 2) + ", " + - hb_ws_msg_light + - String(int(_webUpdater_sensValues[SENSOR_LIGHT]), 2) + ", " + - hb_ws_msg_windspeed + - String(_webUpdater_sensValues[SENSOR_WINDSPEED], 2) + - hb_ws_msg_end); + unsigned int timestamp = 0; + for (int i = 0; i < VALUES; i++) + { + timestamp += int(_webUpdater_sensValues[i]) + millis(); + } + String msg = hb_ws_msg_start + + hb_ws_msg_temp + + String(_webUpdater_sensValues[SENSOR_TEMPERATURE], 2) + + ", " + + hb_ws_msg_humi + + String(_webUpdater_sensValues[SENSOR_HUMIDITY], 2) + + ", " + + hb_ws_msg_light + + String(_webUpdater_sensValues[SENSOR_LIGHT], 2) + + ", " + + hb_ws_msg_windspeed + + String(_webUpdater_sensValues[SENSOR_WINDSPEED], 2) + + ", " + + "\"timestamp\": " + + String(timestamp) + + hb_ws_msg_end; + + httpServer.send(200, "text/html", msg); } void resetWifiManager()