Bosch Sensortec Community

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

    can i calculate iaq without bsec_iot_loop() function

    pallyapd
    Member

    can i calculate iaq without bsec_iot_loop() function

     

    I am using bme680 for iaq calculation and another sensor is one of optical sensor which gives some optical data ...because of infinite bsec_iot_loop i can't do anything for this optical sensor .so please help me how to do other tasks while using Bsec_iot_loop(), I also trying timer-based interrupt to read optical data but after some time error occurs.is any method to calculate iaq .I have used the nrf52840 controller .and i want to run only one thread so please help me also i post my query on the community forum.

    8 REPLIES 8
    BSTRobin
    Community Moderator

    Re: can i calculate iaq without bsec_iot_loop() function

    Hello pallyapd,

    nrf52840 had freertos support, you could start a task for optical sensor, and start another task for BSEC, run bsec_iot_loop().

    pallyapd
    Member

    Re: can i calculate iaq without bsec_iot_loop() function

    i don't want to use freertos .my application include ble mesh and all framework is ready .so any other way to solve this instead of this os.?

    gbeloev
    Member

    Re: can i calculate iaq without bsec_iot_loop() function

    Hi,

    You can certainly avoid using bsec_iot_loop() in your code. I think that is just an example provided by Bosch. In my code I implemented a function to perform the equivalent functionality but without the loop. The key is to pass the current timestamp to bsec_sensor_control(), which in turn tells you if measurements should be run, and also when to run the next measurement. Then in your code use a timer or another method to delay the next call until the appropriate time.

    So basically (simplified):

        int64_t time_stamp = get_timestamp_us() * 1000ULL;
    
    bsec_sensor_control(time_stamp, &sensor_settings); bme680_bsec_trigger_measurement(&sensor_settings, sleep); bme680_bsec_read_data(time_stamp, bsec_inputs, &num_bsec_inputs, sensor_settings.process_data); bme680_bsec_process_data(bsec_inputs, num_bsec_inputs, output_ready);
    int64_t time_stamp_interval_ms = (sensor_settings.next_call - get_timestamp_us() * 1000ULL) / 1000000ULL; return (time_stamp_interval_ms > 0) ? time_stamp_interval_ms : 0;

    I hope this helps.

    BSTRobin
    Community Moderator

    Re: can i calculate iaq without bsec_iot_loop() function

    Hello gbeloev,

    Thanks for your sharing.
    Yes, we can modify it to the code we want based on the example code. @pallyapd, could your refer gbeloev's suggestion for your SW platform?

    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