09-17-2023 01:03 PM - edited 09-18-2023 02:23 PM
Hi
I am using BSEC library with BME680 5min interval. The flow of our device goes like this:
bsec_iot_loop(bme680_sleep, esp_timer_get_time, output_ready, state_save, 1/* 10000 */);
The problem is that accuracy is always 0. Appreciate your support on this and if I misunderstood the whole mechanism.. the assumption is that we'll store the state regardless of the accuracy, as it should be cumulatively changed to acc=3 over time.. also I didnt change the timestamp, so each time the device restart (wake-up from deep sleep it'll start counting from the beginning, since in my implementation the uC is completely off), each time it will reset, assuming it will load the state regardless of the timestamp since it should start from there? or I should only store it if its acc=3? Appreciate more clarification.
Note: The sensor works perfectly in normal operation, with 5 min intervals; no deepsleep.
09-21-2023 08:24 AM
Hi BSTRobin
1-Timestamp is the same each run. Again I really appreciate your elaboration on the timestamp concept, is it mandatory in the BSEC calculation for IAQ? or only to calculate the sleep duration?
2-BSEC_1.4.8.0
09-21-2023 10:36 AM
Hi Adi,
1.You don't need to save status every 3 seconds with so fast frequency. You can refer to the official example of BSEC1.4.8.0 to modify the time of saving the state.
/*!
* @brief Runs the main (endless) loop that queries sensor settings, applies them, and processes the measured data
*
* @param[in] sleep pointer to the system specific sleep function
* @param[in] get_timestamp_us pointer to the system specific timestamp derivation function
* @param[in] output_ready pointer to the function processing obtained BSEC outputs
* @param[in] state_save pointer to the system-specific state save function
* @param[in] save_intvl interval at which BSEC state should be saved (in samples)
*
* @return none
*/
void bsec_iot_loop(sleep_fct sleep, get_timestamp_us_fct get_timestamp_us, output_ready_fct output_ready,
state_save_fct state_save, uint32_t save_intvl)
main()
{
...
/* Call to endless loop function which reads and processes data based on sensor settings */
/* State is saved every 10000 samples, which means every 10000 * 3 secs = 500 minutes */
bsec_iot_loop(sleep, get_timestamp_us, output_ready, state_save, 10000);
...
}
2.Timestamp will be not same. Ensure that the timestamp is the real-time system time, otherwise BSEC will not function properly.
09-21-2023 11:00 AM
Thanks for your fast response!
1-I am saving 1 state each 300s not 3s.
2-Timestamp is not clear for me here, real-time system time, what is the calculation for it? Assuming 1st data collection happened at 10:00:00AM next expected sample will be at 10:05:00 (for 300s freq.) How to calculate timestamp value? since it's expecting long long int data type, please excuse my ignorance here, but its not c? I really appreciate your support,
09-21-2023 11:20 AM
Hi Adi,
1.In you code "bsec_iot_loop(bme680_sleep, esp_timer_get_time, output_ready, state_save, 1/* 10000 */);", 1 means 1*3 seconds.
2.You can get real-time from RTC. For example on STM32 paltfrom, I get real-time from RTC like this:
int64_t get_timestamp_us()
{
int64_t system_current_time = 0;
// ...
// Please insert system specific function to retrieve a timestamp (in microseconds)
// ...
uint32_t tick;
tick = HAL_GetTick();
system_current_time = 1000*(int64_t)tick;
return system_current_time;
}
09-21-2023 01:18 PM
Thanks!
1- the profile we are using is 300s, so its one sample that is going to be saved each 300s (5min). Please let me know if I misunderstood it.
2- Timestamp is the delta between two wakeup?