Bosch Sensortec Community

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

    Reading multiple BME688 with Bsec2

    Reading multiple BME688 with Bsec2

    hugehead
    Established Member

    Hello,

    I would like to readout multiple BME688 simultaniously. I created two instances of Bsec2, and afterwards i do each step for both instances. I kept the NewDataCallback the same, as one input parameter is the BSEC instance. In BSEC2 i get an error 100 from BSEC2.

    Please let me know what is the problem .

    Bsec2 envSensors[2];

     

       for(int i = 0; i < NUMBEROFDEVICES; i ++)
          {
              
    
              //Set multiplexer
    
              if (!envSensors[i].begin(BME68X_I2C_ADDR_LOW, Wire))
              {
                  checkBsecStatus(envSensors[i]);
              }
          
              /* Subsribe to the desired BSEC2 outputs */
              if (!envSensors[i].updateSubscription(sensorList, ARRAY_LEN(sensorList), BSEC_SAMPLE_RATE_LP))
              {
                  checkBsecStatus(envSensors[i]);
              }
              
              /* Whenever new data is available call the newDataCallback function */
              envSensors[i].attachCallback(newDataCallback);
              envSensors[i].index = i;
              Serial.println("BSEC library version " + \
                String(envSensors[i].version.major) + "." \
                + String(envSensors[i].version.minor) + "." \
                + String(envSensors[i].version.major_bugfix) + "." \
                + String(envSensors[i].version.minor_bugfix));
                
          }
    
    
    }

     

    if (!envSensors[i].begin(BME68X_I2C_ADDR_LOW, Wire))
    {
    checkBsecStatus(envSensors[i]);
    }

     

     

    I checked the Arduino example for x8 board, which has 8 times BME688 and Multiplexer. It seems like the example is reading and processing only 1 BME688 sensor.

    Kind Regards

    23 REPLIES 23

    BSTRobin
    Community Moderator
    Community Moderator

    Hello hugehead,

    You could modify macro definition SENS_NUM to support multiple sensor.

    /* sensors are numbered 0-7 */
    #define SENS_NUM 0

    Hello hugehead, You could modify macro definition SENS_NUM to support multiple sensor. /* sensors are numbered 0-7 */ #define SENS_NUM 0

    hugehead
    Established Member

    Hello Robin,

    I do not understand how i could manage to read out multiple sensors with that method. I can change the sensor, compile, flash and run the code. Then i can change again, compile, flash and run on different BME688.

    /* sensors are numbered 0-7 */
    #define SENS_NUM 1

    /* sensors are numbered 0-7 */
    #define SENS_NUM 2

    I would like to have a program that iterates over mutiple sensors during runtime. In the X8 Board-Case, I would like to iterate over the 8 sensors and read them one by one during runtime. With this X8 example it is not possible, as it is running only on 1 instance of Bsec2.

    I sent you an example i created in arduino, to read 2x BME688 Pi 3g heads with I2C address 0x77 and 0x76. In there, i create 2 instances of Bsec2 and read them in a loop. In the output of that example (i shared in previous message), I can see from "gas resistance"  that it is reading 2 different sensors, with unexpected timing. It is like 3 times reading envSensor1 and 3 times reading envSensor2. It should be reading alsways envSensor1, envSensor2, envSensor1, envSensor2. The values should be coming every ~ 3 seconds, what i saw in example with single sensor.

    I am getting the warning 100. What is it about? How can i get rid of this warning 100? Do I have to save the current state of the library for each Bsec2 instance?  Right now i am using one library for 2 sensors. Is that intended to work properly? Please help me to find a solution for this.

     

     

     

    Hi,

    I have the exact same problem on the BME888 development kit with the x8 basic example. If you want to have continuous data readouts from 2 sensors, it simply doesn't work. Only one sensor is giving a readout via the callback. The other ones gives back a "100" BSEC status.

    It seems to me that trying to read sensor status messes the data readouts via the callback.

    Is there any plan to release a basic arduino example on how to read multiple sensors at the specified data rate ?

    Best regards

    BSTRobin
    Community Moderator
    Community Moderator

    Hello hugehead,

    Warning 100 means difference between actual and defined sampling intervals of bsec_sensor_control() greater than allowed.
    Please ensure that your system calls bsec_sensor_control() at the time instructed in the previous call, a maximum jitter of 6.25% is allowed.

    hugehead
    Established Member

    Hello Robin,

    Thank you for the answer. I know already that this error is related to the timing. The timing is handled by the Libraries , i get the timestamp for the next call by "bsec_sensor_control".

    As i have multiple instances of BSEC2, I made use of "bsec_set_state" and "bsec_get_state" for each of my BSEC2 instances. Still, I need to call the function "bsec_sensor_control" for each of my instances to get proper timestamp. The library, then, gives the error, because i run the funtion "bsec_sensor_control" too fast to get new timestamp.

    My main question stays valid: how can i read out multiple BME688 at the same time. There is no example code for this available. I already create an issue in github repo, with no response. Please, could you get someone from the dev team to find out a solution on this? It seems i am not the only one trying to get this done.

    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