Bosch Sensortec Community


    BME680 : Using BSEC in backend

    New Poster

    BME680 : Using BSEC in backend


    Is there any way we can run BSEC library outside of the microcontroller ?


    Details :

    I want to use BSEC library to get VOC readings from BME680.

    But maximum flash memory size is 192KB (STM32L073RZ), and when using BSEC the binaries are 271KB.

    Can I let's say make simple gas measurements on MCU, then convert the data in the cloud using BSEC ?

    Tags (2)
    2 REPLIES 2
    Community Moderator

    Re: BME680 : Using BSEC in backend

    Yes, this is possible, with a few limitations. For instance, the sensor should run with a fixed configuration, according to the desired operating mode (ULP or LP). Therefore the ULP+ feature isn't supported anymore.

    An Arduino library is included in BSEC's package to show how the sensor should be configured, with the following snippet extracted from bme680_data.h:

    /* Macro definitions */
    #define BSEC_HUMIDITY_OVERSAMPLING       UINT8_C(1)            /*!< Humidity oversampling rate */
    #define BSEC_TEMPERATURE_OVERSAMPLING    UINT8_C(2)            /*!< Temperature oversampling rate */
    #define BSEC_PRESSURE_OVERSAMPLING       UINT8_C(5)            /*!< Pressure oversampling rate */
    #define BSEC_HEATER_TEMP_LP              UINT16_C(320)         /*!< Low Power mode heater temperature */
    #define BSEC_HEATING_DURATION_LP         UINT16_C(197)         /*!< Low Power mode heating duration */
    #define BSEC_HEATER_TEMP_ULP             UINT16_C(400)         /*!< Ultra Low Power mode heater temperature */
    #define BSEC_HEATING_DURATION_ULP        UINT16_C(1943)        /*!< Ultra Low Power mode heating duration */

    Attached is an example project that is based on the original bsec_integration.c sample code,  but was edited to use a csv file containing raw sensor data as input, and generating another csv file with BSEC's outputs. It includes:

    • bme680_remote_BSEC_run.c, bsec_integration_backend.c and bsec_integration_backend.h, the sample code,
    • datalog.csv, an example of raw sensor log from a BME680 (including the necessary timestamp, raw temperature/pressure/humidity/gas resistance) in a .csv file in a format expected by the sample code above,
    • bsec_output.csv, an example of output generated by the sample code above when datalog.csv was used as input file.

    To run the example above, you will need to add the library headers (bsec_interface.h and bsec_datatypes.h) from your BSEC package, as well as the pre-compiled library for your platform (BSEC v1.4.7.3 was used in this project, therefore it is recommended to use at least this version).

    To generate bsec_output.csv, BSECLibrary64.dll was used, and compiled in a COINES environment in Windows 10's CMD:

    C:\Users\username\Documents\BME680_remote_BSEC_run>bme680_remote_BSEC_run.exe -i datalog.csv -o bsec_output.csv
    input file: datalog.csv
    output file: bsec_output.csv
    BSEC initilization complete, now running BSEC...
    BSEC processing complete!


    New Poster

    Re: BME680 : Using BSEC in backend

    Thank you very much for your helpful answer.