01-13-2022 08:56 AM
Hello I am working on BME680 sensor for my enviromental project, As per suggestion I am using BSEC Library, I have intedgrated with my MCU and it works fine , while reading continuously , This was my fist phase of the project which is completed, But now I want to my MCU to be in low power mode , My MCU will goes into sleep mode for 5 mins and wake up collect data from the BME680 and then goes to sleep. But the provlem occurs here , when the MCU runs in continous mode IAQ accuracy works fine ( 0 , 1 ,2 and 3) , Like for example when the IAQ accuracy is set to 1 or 2 , and then I active the sleep mode , after five minutes when the MCU wakes up , I notice that IAQ accuracy is reset to zero (0). I am working from last one week yet the problem still exists.
Any help regarding this will much be appreciated.
Thanks
while (1)
{
if ( onoffflag == 1 )
{
/* get the timestamp in nanoseconds before calling bsec_sensor_control() */
time_stamp = get_timestamp_us() * 1000;
/* Retrieve sensor settings to be used in this time instant by calling bsec_sensor_control */
bsec_sensor_control(time_stamp, &sensor_settings);
/* Trigger a measurement if necessary */
bme680_bsec_trigger_measurement(&sensor_settings, sleep);
/* Read data from last measurement */
num_bsec_inputs = 0;
bme680_bsec_read_data(time_stamp, bsec_inputs, &num_bsec_inputs, sensor_settings.process_data);
/* Time to invoke BSEC to perform the actual processing */
bme680_bsec_process_data(bsec_inputs, num_bsec_inputs, output_ready);
/* Increment sample counter */
n_samples++;
/* Retrieve and store state if the passed save_intvl */
if (n_samples >= save_intvl)
{
bsec_status = bsec_get_state(0, bsec_state_loop, sizeof(bsec_state_loop), work_buffer, sizeof(work_buffer), &bsec_state_len_loop);
if (bsec_status == BSEC_OK)
{
state_save(bsec_state_loop, bsec_state_len_loop);
}
n_samples = 0;
}
/* Compute how long we can sleep until we need to call bsec_sensor_control() next */
/* Time_stamp is converted from microseconds to nanoseconds first and then the difference to milliseconds */
time_stamp_interval_ms = (sensor_settings.next_call - get_timestamp_us() * 1000) / 1000000;
if (time_stamp_interval_ms > 0)
{
sleep((uint32_t)time_stamp_interval_ms);
}
}
01-13-2022 09:12 AM
Hello msalmankhan334,
You could refer the following FAQ from BSEC integration guide to check it first.
01-13-2022 10:26 AM - edited 01-13-2022 10:29 AM
yes i have read this before , When my MCU contineously reading data , the IAQ accuracy works fine , As you can see I have a flag "onoffflag" , during normal mode this flag remain set to ''1', But when i activate the sleep mode 'onoffflag' set to 0, so no more communication with the BME680 during sleep mode activation and when the MCU wakes up it then start communication with the BME680 sensor.
what I can set or to store so that I need to save setting and when wakeup i need to load , so that the calibration of the sensor is not lost during the sleep mode.
Thanks
01-17-2022 09:32 AM
Hello msalmankhan334,
Could you send out your project code, let us check it.
By the way, is it normal when MCU work without sleep mode?