07-21-2023 09:32 AM - edited 07-21-2023 09:34 AM
Hello,
I'm using the BME680 with a STM32WLE and everthing was working well.
Between the 03/06 to 21/07 everything was ok but after the bsec IAQ values are competly wrong.
I'm wondering if that is not related to the timestamp hat can fail after reaching max value.
Thanks
08-28-2023 03:13 PM
Hello
I think i found the issue
The issue is that after 49 days we have the rollover of HAL_GetTick();
So it restart from 0 and the BSEC algo stop working
Here a fix
int64_t get_timestamp_us()
{
static uint32_t previous_tick = 0; // La dernière valeur de tick lue
static int64_t overflow_count = 0; // Compte les débordements
uint32_t tick = HAL_GetTick();
if(tick < previous_tick) {
overflow_count += (int64_t)0xFFFFFFFF + 1; // Incrémente par 2^32
}
previous_tick = tick;
int64_t system_current_time = 1000 * (overflow_count + tick);
return system_current_time;
}
08-30-2023 08:50 PM
Hi Hamady,
For timestamp in BSEC2, you have to use micro second unit of 64 bit timestamp.
Otherwise, you will get error like you faced.
Thanks for letting us know.