diff --git a/include/etc/pwr_save_configuration.h b/include/etc/pwr_save_configuration.h index ea2daa8..ed8f54c 100644 --- a/include/etc/pwr_save_configuration.h +++ b/include/etc/pwr_save_configuration.h @@ -11,13 +11,15 @@ /** - * This is cutoff voltage at which the power saving subsystem will keep ParaMETEO constantly - * in L7 mode and wakeup once every 20 minutes to check B+ once again + * This is cutoff voltage (momentary / non averaged) at which the power saving + * subsystem will keep ParaMETEO constantly in L7 mode and wakeup once + * every PWR_SAVE_CUTOFF_SLEEP_TIME_IN_MINUTES minutes to check B+ once again */ #define PWR_SAVE_CUTOFF_VOLTAGE_DEF 1100u // 11.0V /** - * This is the restore voltage a battery must be charged to for ParaMETEO to restore it's normal operation + * This is the restore voltage (averaged) a battery must be charged to + * for ParaMETEO to restore it's normal operation */ #define PWR_SAVE_STARTUP_RESTORE_VOLTAGE_DEF 1200u // 12.0V @@ -26,6 +28,14 @@ */ #define PWR_SAVE_AGGRESIVE_POWERSAVE_VOLTAGE 1130u // 11.3V +/** + * How much average battery voltage must be greater than + * current (momentary) voltage to go to cutoff WHEN + * this current (momentary) voltage is below + * PWR_SAVE_CUTOFF_VOLTAGE_DEF + */ +#define PWR_SAVE_CUTOFF_AVG_VOLTAGE_MARGIN 100u // 0.1V + /** * How long in minutes the controller will sleep in L7 state between checking * if battery has been charged. diff --git a/include/main.h b/include/main.h index 53e3187..71fb107 100644 --- a/include/main.h +++ b/include/main.h @@ -15,7 +15,7 @@ #define SYSTICK_TICKS_PER_SECONDS 100 #define SYSTICK_TICKS_PERIOD 10 -//#define INTERNAL_WATCHDOG +#define INTERNAL_WATCHDOG #define EXTERNAL_WATCHDOG #define PWR_SWITCH_BOTH diff --git a/include/rte_wx.h b/include/rte_wx.h index 2b61000..aae0e10 100644 --- a/include/rte_wx.h +++ b/include/rte_wx.h @@ -80,7 +80,7 @@ extern float_average_t rte_wx_dallas_average; extern ms5611_qf_t rte_wx_ms5611_qf; extern bme280_qf_t rte_wx_bme280_qf; extern analog_wind_qf_t rte_wx_wind_qf; - +extern uint8_t rte_wx_humidity_available; extern umb_frame_t rte_wx_umb; diff --git a/include/software_version.h b/include/software_version.h index f8458fd..6f360ba 100644 --- a/include/software_version.h +++ b/include/software_version.h @@ -9,7 +9,7 @@ #define SOFTWARE_VERSION_H_ #define SW_VER "EB02" -#define SW_DATE "29102023" +#define SW_DATE "31102023" #define SW_KISS_PROTO "B" extern const char software_version_str[5]; diff --git a/src/packet_tx_handler.c b/src/packet_tx_handler.c index 36d6b61..8ae3a1a 100644 --- a/src/packet_tx_handler.c +++ b/src/packet_tx_handler.c @@ -442,6 +442,23 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con humidity_qf = HUMIDITY_QF_NOT_AVALIABLE; } + // additional check for modbus RTU humidity sensor + if (config_mode->wx_modbus == 1) { + // for sake of simplicity there is another variable + // which holds common information if valid humidity + // is available or not. This is kinda-sorta duplication of + // quality factors for each sensor types, although it + // simplifies few things and omits handling separate + // Modbus-RTU configuration here + if (rte_wx_humidity_available == 0) { + humidity_qf = HUMIDITY_QF_NOT_AVALIABLE; + } + else if (rte_wx_humidity_available == 1) { + humidity_qf = HUMIDITY_QF_FULL; + } + + } + // wind quality factor if (rte_wx_wind_qf == AN_WIND_QF_UNKNOWN) { ; diff --git a/src/pwr_save.c b/src/pwr_save.c index 1da674b..152ae1a 100644 --- a/src/pwr_save.c +++ b/src/pwr_save.c @@ -894,7 +894,7 @@ config_data_powersave_mode_t pwr_save_pooling_handler( const config_data_mode_t backup_reg_set_monitor(23); } else { - if (vbatt_current <= PWR_SAVE_CUTOFF_VOLTAGE_DEF && vbatt_average <= PWR_SAVE_AGGRESIVE_POWERSAVE_VOLTAGE) { + if (vbatt_current <= PWR_SAVE_CUTOFF_VOLTAGE_DEF && vbatt_average <= (PWR_SAVE_CUTOFF_VOLTAGE_DEF + PWR_SAVE_CUTOFF_AVG_VOLTAGE_MARGIN)) { backup_reg_set_monitor(22); // if the battery voltage is below cutoff level and the ParaMETEO controller is currently not cut off diff --git a/src/rte_wx.c b/src/rte_wx.c index 6a12f6d..6d7b67c 100644 --- a/src/rte_wx.c +++ b/src/rte_wx.c @@ -65,6 +65,7 @@ float_average_t rte_wx_dallas_average; ms5611_qf_t rte_wx_ms5611_qf = MS5611_QF_UNKNOWN; bme280_qf_t rte_wx_bme280_qf = BME280_QF_UKNOWN; analog_wind_qf_t rte_wx_wind_qf = AN_WIND_QF_UNKNOWN; +uint8_t rte_wx_humidity_available = 0; umb_frame_t rte_wx_umb; diff --git a/src/wx_handler_humidity.c b/src/wx_handler_humidity.c index de8e3ad..41d6daa 100644 --- a/src/wx_handler_humidity.c +++ b/src/wx_handler_humidity.c @@ -27,7 +27,7 @@ int32_t wx_get_humidity_measurement(const config_data_wx_sources_t * const confi // // but MS5611 isn't a humidity sensor - ; + rte_wx_humidity_available = 2; } else { // BME280 @@ -36,6 +36,11 @@ int32_t wx_get_humidity_measurement(const config_data_wx_sources_t * const confi // if humidity has been retrieved successfully if (measurement_result == BME280_OK) { rte_wx_humidity_valid = rte_wx_humidity; + + rte_wx_humidity_available = 1; + } + else { + rte_wx_humidity_available = 0; } } @@ -58,6 +63,10 @@ int32_t wx_get_humidity_measurement(const config_data_wx_sources_t * const confi rte_wx_humidity_valid = rte_wx_humidity; + rte_wx_humidity_available = 1; + } + else { + rte_wx_humidity_available = 0; } break;