Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BSEC library design seems to prohibit multiple instances within one process

    BSEC library design seems to prohibit multiple instances within one process

    New Poster

    hi folks,

    I am not sure, if my approach is a good one, or if I simply do not fully understand how things work, yet. It would be great, if you could give me some hints to get it working 🙂

    In my use case I want to calculate the iAQ values of multiple BME680 sensors on a RaspberryPi or x86. The sensors are running on very low end Arduinos (328p) and send the raw data to the x86/RPi.

    For this, I created an array of multiple BSEC objects, which I feed whenever new raw data arrive from the sensors:

    My_BSEC bsec[2];      // Array of My_BSEC, a class wrapping and managing the bsec functions (e.g. bsec_set_configuration, bsec_update_subscription, bsec_sensor_control, bsec_do_steps, ...)
    bsec[bsecId].calculateData(input);   // one sensor is fed with new data

    With following input:

    bsec[0].calculateData(F105C79AB0000014279641C1DE6847DB23704231A17048); // sensor one is fed with new data
    bsec[1].calculateData(F105C79AB0000014279641C1DE6847DB23704231A17049); // sensor two is fed with slightly different data, but the same timestamp

    ... BSEC returns warning 4 

    // from bsec_datatypes.h: BSEC_W_DOSTEPS_TSINTRADIFFOUTOFRANGE = 4, /*!< Duplicate timestamps passed to bsec_do_steps() */)


    This indicates, that altough there are two separate instances of My_BSEC in my code, the same bsec data structures are used in the background/ external library. The BSEC library has only one context.

    Am I mistaken or is this wanted or expected behaviour?
    Some code is attached (sorry for using the Qt framwork, it is not really a minimal example)

    Best Regards,


    3 REPLIES 3


    I guess you are right with the assumption that there is only one underlying data instance.

    But simply feeding in the raw data of each sensor with a different unique timestamp should be an easy workaround.

    Community Moderator
    Community Moderator

    Hello MightyNate,

    Currently, BSEC algorithm only supported to analyse one sensor data. On SW driver side, you could read different sensors's data via I2C or SPI.
    The algorithm needs to continuously analyze the data, which takes some time. It is suggested that the same instances analyze the data of one sensor.


    thank you both for your replies. I guess I will stick to the one process one sensor approach / workaround 😕