Bosch Sensortec Community

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

    BME680 BSEC how to connect

    BME680 BSEC how to connect

    Yuriy
    New Poster

    I connected the BME680 sensor using the BME680_driver (3.5.10 from 01/23/2020). The sensor works well.
    I need to connect the BSEC library. I found BSEC_1.4.7.4_Generic_Release, but cannot figure out how to do this correctly. I am reading BST-BME680-Integration-Guide-AN008-47.pdf, I need to connect bsec_interface.h, bsec_datatypes.h, bsec_integration.h, bsec_integration.c. But files are found many times. For example, ..... BSEC_1.4.7.4_Generic_Release \ algo \ normal_version \ bin \ IAR7 \ Cortex_M3 and ...... BSEC_1.4.7.4_Generic_Release \ algo \ normal_version \ contains files with identical names that must be on connection?
    Where to get the rest of the files?
    I managed to compile the project in IAR7, but it does not work. I need files for IAR7, using STM32f103. Where to get the files, and how to connect?

    6 REPLIES 6

    handytech
    Community Moderator
    Community Moderator

    BSEC's header files (bsec_datatypes.h and bsec_interface.h) can be found in different folders, but they should provide the exact set of functions, therefore you only need to pick them once (for example from the same folder as libalgobsec.a).

    Based on your platform description (IAR7 + STM32F103), it looks like you already have found the correct folder for the library's binary file: "BSEC_1.4.7.4_Generic_Release\algo\normal_version\bin\IAR7\Cortex_M3\libalgobsec.a".

    The example code (bsec_integration.c, bsec_integration.h and bsec_iot_example.c) can be found under the 'examples' folder: "BSEC_1.4.7.4_Generic_Release\examples\".

    Please also make sure that your specific part number has sufficient RAM/ROM available for the BSEC library (STM32F103 offers many variants with variable memory size, you can find the expected requirements for BSEC on its download page or directly inside the package).

    Let's do it in order.
    As a test case, I use STM32F103C8T6, I2C connection.
    From ... ..BSEC_1.4.7.4_Generic_Release \ algo \ normal_version \ bin \ IAR7 \ Cortex_M3 the files bsec_datatypes.h, bsec_interface.h, libalgobsec.a are connected.
    From ... ..BSEC_1.4.7.4_Generic_Release \ examples files bsec_integration.c, bsec_integration.h.
    From ... ..BSEC_1.4.7.4_Generic_Release \ API files bme680.c, bme680.h, bme680_defs.h, when connecting the sensor without BSEC, I used these files with a more recent version, but in this case, I decided to use from BSEC_1.4.7.4 .
    After compilation, I get 43 Kb, if without bsec_iot_loop (), then about 23Kb.
    As a result, on the logic analyzer I see an I2C call to DS3231 (used for the test), after that there are no pulses. SDA and SCL level 1.
    There may be an error in config_load ().
    What am I wrong about?

    I figured out what the problem is. Too many variables, the stack size was insufficient. Perhaps someone will come in handy, try to increase the stack if problems arise.
    The code size turned out to be significantly larger than indicated in the description.
    The firmware only works if any code optimization is turned off in the compiler settings.
    I have one question.
    state_save () saves some bytes to non-volatile memory. How many bytes? I have 139 bytes stored, is this value constant or can it change?

    handytech
    Community Moderator
    Community Moderator

    @Yuriy wrote:

    I figured out what the problem is. Too many variables, the stack size was insufficient. Perhaps someone will come in handy, try to increase the stack if problems arise.
    The code size turned out to be significantly larger than indicated in the description.
    The firmware only works if any code optimization is turned off in the compiler settings.


    Thanks for the update and letting us know what was the issue.


    @Yuriy wrote:

    I have one question.
    state_save () saves some bytes to non-volatile memory. How many bytes? I have 139 bytes stored, is this value constant or can it change?


    bsec_get_state() can be used to read-out the current state of BSEC. This state string can then be saved to some non-volatile memory, and later restored to BSEC with bsec_set_state(). The size of the state string is constant for a specific BSEC version. In the current BSEC release (v1.4.7.4) the state has indeed a fixed length 139 bytes as indicated by the BSEC_MAX_STATE_BLOB_SIZE macro in bsec_datatypes.h.

    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