Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BSEC BME680 measures 10 times then stops.

    BSEC BME680 measures 10 times then stops.

    acanthe
    Member

    I am attempting to get the BME680 up and running on the nrf52840dk board and I am using the iot example provided code.

    My problem is that after a certain amount of time (its the same timestamp), output_ready is no longer called and only bme680_get_sensor_mode is called every ~33 seconds despite being on LP mode.

    I'm hoping for some guidance in how to start troubleshooting this because I am a little lost as to what I can do without modifying the bsec library. The numbers at the end of the status values are tags I added for identification (so I knew which one was called).

    I have attached the .c file for the iot_example I am using and the main function is below (its just the stock code included):

    /*---------------------------------------------------------------------------*/
    PROCESS_THREAD(env_test_process, ev, data)
    {

    PROCESS_BEGIN();

    return_values_init ret;
    i2c_init();
    ret = bsec_iot_init(BSEC_SAMPLE_RATE_LP, 0.0f, bus_write, bus_read, sleep, state_load, config_load);
    if (ret.bme680_status)
    {
    LOG_INFO_("Could not initialise BME680\n");
    }
    else if (ret.bsec_status)
    {
    LOG_INFO_("Could Not Initialise BSEC Library\n");
    }

    bsec_iot_loop(sleep, get_timestamp_us, output_ready,state_save, 10000);
    PROCESS_END();
    }

    /*---------------------------------------------------------------------------*/

    LOG OUTPUT:

    __________________________

    ------------MEASUREMENTS----------x100--------
    bsec_status: 0
    timestamp: 24101562000
    IAQ index: 2500, Accuracy: 0
    Temperature: 2900
    Humidity: 4600
    Pressure: 10020800
    Gas: 2773500
    CO2 Equivalent: 0
    VOC Equivalent: 0
    bme680_status = 0 4
    bme680_status = 0 3
    bme680_status = 0 1
    bme680_status = 0 6
    bsec_status = 0 5

    ------------MEASUREMENTS----------x100--------
    bsec_status: 0
    timestamp: 27101562000
    IAQ index: 2500, Accuracy: 0
    Temperature: 2900
    Humidity: 4600
    Pressure: 10020400
    Gas: 2983900
    CO2 Equivalent: 0
    VOC Equivalent: 0
    bme680_status = 0 4
    bme680_status = 0 3
    bme680_status = 0 1
    bme680_status = 0 6
    bsec_status = 0 5

    ------------MEASUREMENTS----------x100--------
    bsec_status: 0
    timestamp: 30101562000
    IAQ index: 2500, Accuracy: 0
    Temperature: 2900
    Humidity: 4600
    Pressure: 10020800
    Gas: 3168200
    CO2 Equivalent: 0
    VOC Equivalent: 0
    bme680_status = 0 4
    bme680_status = 0 3
    bme680_status = 0 1
    bme680_status = 0 6
    bsec_status = 0 5

    ------------MEASUREMENTS----------x100--------
    bsec_status: 0
    timestamp: 33109375000
    IAQ index: 2500, Accuracy: 0
    Temperature: 2900
    Humidity: 4600
    Pressure: 10020800
    Gas: 3320700
    CO2 Equivalent: 0
    VOC Equivalent: 0
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1
    bme680_status = 0 1

    12 REPLIES 12

    Minhwan
    Community Moderator
    Community Moderator

    Hello acanthe, 

     

    Thanks for your reply. 

    One question more. It seems like you don't change any thing from our reference code. 

    Is your hardware our application board? 

    BME680 shuttle board + App 2.0? 

    If not, each board are you using it? 

    Could you captur all logs you can and logic analyzer? 

    Thanks, 

    Hi,

    I am using the NRF52840dk board (PCA10056) to interact with the BME 680.

    Unfortunately I cannot use the logic analyser with my current setup. I am using contiki-NG for my platform as that handles the radio comms down the line.

    I have attached the logs that I have gathered by adding print statements to the functions in bsec_intergration.c

    As you can see it starts off fine, sleeping for 2718 ms and calling set sensor mode + get sensor data but then stops for some reason after a few cycles, with a sleep time of 33500ms instead. Is there any reason the sensor_settings-> trigger_measurement should turn off in this example (in bsec_intergration line 244)? i feel like that may be the cause of all this since once that value is 0 it stops measuring, then sets the sleep timer to 33.5s. Is this maybe a configuration problem?

    I have tried to make the code I used match the example as closely as possible. I have attached my i2c functions incase you think there might be a problem there

    Minhwan
    Community Moderator
    Community Moderator

    Hello Acanthe, 

     

    I briefly checked your code, and could you give some log regrading get_timestamp_us? 

    your log.h looks like timestamp doesn't work properly. 

    Thank you. 

    Hi, Seems like you were right, the timestamp output is set to 2657000 and stays there after 33.5s of system time.

    Added  the logs with the get_timestamp_us call to it.

    what I am seeing is this (bsec_integration line 637):

    time_stamp_interval_ms = (sensor_settings.next_call - get_timestamp_us() * 1000) / 1000000;
    return time_stamp_interval_ms;

    after a few times get_timestamp_us is returning the time_stamp_interval_ms value of 2.7s instead of the system time which is why it keeps outputting the 33.5s runtime.

    33.5s seems to be the maximum value of the clock before it is resetting which seems to be causing the problem. Any advice on how to handle the clock timer exceeding max value for BSEC scheduling?

    NOTE: my max value is 33.5s because my system clock seems to be of type uint32_t and CLOCK_SECOND is 128 (4,294,967,295/128 = 335....)

    Minhwan
    Community Moderator
    Community Moderator

    Hello Acanthe, 

     

    There is one moe thing from your code. 

    get_timestamp_us is micro second unit. Why did you multiply 1000000 and devide clock_second? 

    I don't think you need that process if the unit of your clock time function is micro second. 

    int64_t get_timestamp_us()
    {
        int64_t system_current_time = (clock_time()*1000000)/CLOCK_SECOND;
        // ...
        // Please insert system specific function to retrieve a timestamp (in microseconds)
        // ...
        return system_current_time;
    }
    

     If the unit is mili second, just multiply 1000. 

    Does your clock time have 32 bits output or 64 bits? 

    Thank you. 

    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