Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    IAQ Accuracy Resets (0) when my MCU Goes into sleep mode and then wake up

    IAQ Accuracy Resets (0) when my MCU Goes into sleep mode and then wake up

    msalmankhan334
    Occasional Visitor

    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

    This is the initializationThis is the initialization

    IoT endless loopIoT endless loop

     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);
              }
    }
    3 REPLIES 3

    BSTRobin
    Community Moderator
    Community Moderator

    Hello msalmankhan334,

    You could refer the following FAQ from BSEC integration guide to check it first.

    FAQ.png

    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

    BSTRobin
    Community Moderator
    Community Moderator

    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?

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist