diff --git a/firmware/config.h b/firmware/config.h index 1712f62..5509e72 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -13,7 +13,7 @@ #define RESET_ESP_TIME_INTERVAL_MS (60*60*12*1000) // reset every 12 hours #define WIND_SENSOR_MEAS_TIME_S 15 #define WATCHDOG_TIMEOUT_MS 30000 -#define WIFI_CHECK_INTERVAL_MS 60000 +#define WIFI_CHECK_INTERVAL_MS 60000 #define ENERGY_SAVING_ITERATIONS 30 #define WIFI_MINIMUM_SIGNAL_QUALITY 10 // percent #define BAT_LOW_VOLTAGE 3.6 diff --git a/firmware/firmware.ino b/firmware/firmware.ino index b588451..e6cc805 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -55,6 +55,10 @@ void debug(String x) #ifdef DEBUG Serial.println(x); #endif + +#ifdef USE_LOGGER + logdata(String(millis()) + ":" + x); +#endif } //*************************************************************************// @@ -351,6 +355,7 @@ void _loop() debug("read of wind sensor because of high battery enabled"); } #endif + sensor_cnt = 0; fsm_state = FSM_STATE_US; break; @@ -358,7 +363,7 @@ void _loop() debug("read sensor data check"); if (UPDATE_SENSOR_INTERVAL_S * 1000 / DELAY_LOOP_MS <= update_sensor_cnt) { - debug("read sensor data" + String(sensor_cnt)); + debug("read sensor data " + String(sensor_cnt)); if (sensors[sensor_cnt]) { currentSensorData[sensor_cnt] = sensors[sensor_cnt](); } else { @@ -368,10 +373,11 @@ void _loop() if (sensor_cnt < VALUES) { sensor_cnt++; + fsm_state = FSM_STATE_US; // jump to same state again, more sensors to read } else { update_sensor_cnt = 0; sensor_cnt = 0; - fsm_state = FSM_STATE_SC; + fsm_state = FSM_STATE_SC; // next state } } else { debug("skip read sensor data"); @@ -388,7 +394,7 @@ void _loop() break; case FSM_STATE_ID: - debug("Send data to influxdb"); + debug("send data to influxdb if required"); #ifdef INFLUXDB_FEATURE for (uint8_t i = 0; i < 5 and validData == false; i++) { @@ -408,7 +414,7 @@ void _loop() break; case FSM_STATE_SD: - debug("set sensor data in webupdater"); + debug("set sensor data in webupdater if required"); #ifdef WEBUPDATER_FEATURE setSensorData(currentSensorData); #endif @@ -423,7 +429,11 @@ void _loop() //delay(100); // TODO warum hier ein delay? - debug("FSM state = " + String(fsm_state)); + //debug("FSM state = " + String(fsm_state)); + if (fsm_state == FSM_STATE_WU) + { + debug("----------"); + } } void logToSerial(float sensorValues[]) diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 9060e1b..2fc34f6 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -55,7 +55,9 @@ void setupWebUpdater(String device, String ip) #ifdef DEBUG_WINDSPEED_MEASUREMENT httpServer.on("/measWind", measureWindspeed); #endif - +#ifdef USE_LOGGER + httpServer.on("/showlog", showLog); +#endif httpServer.begin(); debug("HTTPUpdateServer ready!"); @@ -139,7 +141,7 @@ void hb_webstat_send(void) void resetWifiManager() { - String message = "