Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME680 Save and Load State Issue

    BME680 Save and Load State Issue

    Adi
    New Poster

    Hi

    I am using BSEC library with BME680 5min interval. The flow of our device goes like this:

    • Wakeup from device deep sleep "uC is off" then on, only external RTC is up,
    • Collect BME680 reading (accuracy 0), save state on each reading in EEPROM

     

     

    bsec_iot_loop(bme680_sleep, esp_timer_get_time, output_ready, state_save, 1/* 10000 */);​

     

     

    • Power-off uC.
    • Wake up, load the previous reading, and get new reading then save state, and so on..

    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.

    14 REPLIES 14

    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

    BSTRobin
    Community Moderator
    Community Moderator

    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.

    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,

    BSTRobin
    Community Moderator
    Community Moderator

    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;
    }

    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?

    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