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