diff --git a/firmware/config.h b/firmware/config.h index 288e9ee..a064015 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -5,9 +5,9 @@ #define WIFI_AUTOCONNECT_TIMEOUT_S 120 #define WIFI_CONFIG_PORTAL_TIMEOUT_S 120 -#define UPDATE_SENSOR_INTERVAL_S 300 +#define UPDATE_SENSOR_INTERVAL_S 180 #define UPDATE_WEBSERVER_INTVERVAL_S 1 // Do not change, bigger values will prevent using webupdater webinterface -#define DELAY_LOOP_MS 50 +#define DELAY_LOOP_MS 100 #define POWERSAVING_SLEEP_S 600 #define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover #define RESET_ESP_TIME_INTERVAL_MS (60*60*12*1000) // reset every 12 hours diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 9e1aa55..4faf8be 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -32,6 +32,15 @@ float currentSensorData[VALUES] = { nanf("no value"), nanf("no value"), nanf("no nanf("no value"), nanf("no value") }; float (*sensors[VALUES])() = {}; +uint8_t sensor_value[] = { SENSOR_TEMPERATURE, + SENSOR_HUMIDITY, + SENSOR_LIGHT, + SENSOR_WINDSPEED, + SENSOR_PRESSURE, + SENSOR_BAT_VOLTAGE, + SENSOR_ESAVEMODE, + SENSOR_BATCHARGESTATE }; + uint32_t update_sensor_cnt = 0; uint32_t update_webserver_cnt = 0; uint32_t update_windspeed_exceed_cnt = 0; @@ -341,13 +350,13 @@ void _loop() debug("read sensor data " + String(sensor_cnt)); if (sensors[sensor_cnt]) { - debug("sensors[" + String(sensor_cnt) + "]=" + String((int)sensors[sensor_cnt])); - //currentSensorData[sensor_cnt] = sensors[sensor_cnt](); - currentSensorData[sensor_cnt] = sensor_cnt; + debug("sensors[sensor_value[" + String(sensor_cnt) + " ]]=" + String((int)sensors[sensor_value[sensor_cnt]]) + ":" + String(sensor_value[sensor_cnt])); + currentSensorData[sensor_cnt] = sensors[sensor_value[sensor_cnt]](); + //currentSensorData[sensor_cnt] = sensor_cnt; } else { - debug("sensors[" + String(sensor_cnt) + "]=nan"); + debug("sensors[sensor_value[" + String(sensor_cnt) + "]]=nan"); currentSensorData[sensor_cnt] = nan("no value"); } @@ -450,6 +459,11 @@ void readWindSpeedExceed() debug("Called windspeed exceed callout"); digitalWrite(STATUS_LED_PIN, LOW); } + +#ifdef WEBUPDATER_FEATURE + setSensorData(currentSensorData); +#endif + } else { currentSensorData[SENSOR_WINDSPEED] = nan("no value"); } diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 1260345..7d23753 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -16,6 +16,8 @@ #include "config.h" #include "config_user.h" +//*************************************************************************// + ESP8266WebServer httpServer(WEB_UPDATER_HTTP_PORT); ESP8266HTTPUpdateServer httpUpdater; @@ -39,6 +41,8 @@ const String hb_ws_msg_end = "}"; boolean wuValidData = false; +//*************************************************************************// + void setupWebUpdater(String device, String ip) { debug("Starting WebUpdater... " + ip); @@ -63,6 +67,8 @@ void setupWebUpdater(String device, String ip) debug("HTTPUpdateServer ready!"); } +//*************************************************************************// + void doWebUpdater(void) { digitalWrite(D0, HIGH); @@ -85,6 +91,8 @@ void setSensorData(float sensorValues[]) } } +//*************************************************************************// + void showHTMLMain(void) { @@ -118,6 +126,8 @@ TR_TD_START_STR + "wifi rssi" + TD_TD_MID_STR + WiFi.RSSI() httpServer.send(200, "text/html", message); } +//*************************************************************************// + #ifdef HOMEBRIDGE_WEBSTAT void hb_webstat_send(void) { @@ -148,6 +158,8 @@ void hb_webstat_send(void) } #endif +//*************************************************************************// + void resetWifiManager() { @@ -170,6 +182,8 @@ void resetWifiManager() ESP.restart(); } +//*************************************************************************// + #ifdef DEBUG_WINDSPEED_MEASUREMENT #ifdef SENSOR_WIND void measureWindspeed() @@ -192,9 +206,11 @@ void measureWindspeed() #endif #endif +//*************************************************************************// + #ifdef USE_LOGGER -#define LOGFILE_SIZE 15 +#define LOGFILE_SIZE 20 String logfile[LOGFILE_SIZE]; @@ -233,3 +249,5 @@ void showLog() } #endif + +//*************************************************************************//