Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Two sampling rates for BME68X board to get all Gas IAQ and Gas Estimate reading

    Two sampling rates for BME68X board to get all Gas IAQ and Gas Estimate reading

    SunilS
    New Poster

    Hi,

    I would like have update_subscription() with both sampling rate , that is,  1) BSEC_SAMPLE_RATE_SCAN & 2)  BSEC_SAMPLE_RATE_LP. If I configure all sensors together, that is, I get BSEC error -12 (indicating wrong sampling rate). As I understand there is exclusive reading of sensor values attached to sampling rate.

    With BSEC_SAMPLE_RATE_SCAN, update subscription works for only

    bsecSensor sensorList[] = {
    BSEC_OUTPUT_RAW_TEMPERATURE,
    BSEC_OUTPUT_RAW_PRESSURE,
    BSEC_OUTPUT_RAW_HUMIDITY,
    BSEC_OUTPUT_RAW_GAS,
    BSEC_OUTPUT_RAW_GAS_INDEX,
    BSEC_OUTPUT_GAS_ESTIMATE_1,
    BSEC_OUTPUT_GAS_ESTIMATE_2,
    BSEC_OUTPUT_GAS_ESTIMATE_3,
    BSEC_OUTPUT_GAS_ESTIMATE_4
    };

     

    And with BSEC_SAMPLE_RATE_LP sampling rate work only for

    bsecSensor sensorList[] = {
    BSEC_OUTPUT_RAW_TEMPERATURE,
    BSEC_OUTPUT_RAW_PRESSURE,
    BSEC_OUTPUT_RAW_HUMIDITY,
    BSEC_OUTPUT_RAW_GAS,
    BSEC_OUTPUT_IAQ,
    BSEC_OUTPUT_STATIC_IAQ,
    BSEC_OUTPUT_CO2_EQUIVALENT,
    BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
    BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
    BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
    };

     

    if so, I have following questions,

    1) what are the ways to combine two sampling rates in a single program / .ino? [integration guide says "To achieve best gas sensor performance, the user shall not switch between different modes during the lifetime of a given sensor."]

    2) can we split 4 sensors for  BSEC_SAMPLE_RATE_SCAN and 4 for BSEC_SAMPLE_RATE_LP each? if yes, what are the config changes required?

    3) What is the association of sensor ID with physcial sensor? [virtual to physical]

     

    2 REPLIES 2

    SunilS
    New Poster

    Update :

    I tried to assign LP rate to 4 virtual sensors and SCAN rate to other 4 virtual sensors. After doing following code changes, I am getting BSEC error code : -16,  (BSEC_E_SU_SAMPLINTVLINTEGERMULT = -16, ).  

    Integration guide error description : The sampling rate of an output requested via bsec_update_subscription() is not an integer multiple of the other
    active sampling rates.

    Question: how to solve this problem? meaning how to have two sampling rates? LP rate for 1st four virtual output sensor and SCAN rate for 2nd four virtual output sensors?

    bsecSensor sensorList1[] = {
    BSEC_OUTPUT_IAQ,
    BSEC_OUTPUT_STATIC_IAQ,
    BSEC_OUTPUT_CO2_EQUIVALENT,
    BSEC_OUTPUT_BREATH_VOC_EQUIVALENT
    };
    bsecSensor sensorList2[] = {
    BSEC_OUTPUT_GAS_ESTIMATE_1,
    BSEC_OUTPUT_GAS_ESTIMATE_2,
    BSEC_OUTPUT_GAS_ESTIMATE_3,
    BSEC_OUTPUT_GAS_ESTIMATE_4
    };
     
     gas_estimate.ino
    /* Subscribe for the desired BSEC2 outputs */
    if (!envSensor[i].updateSubscription(sensorList1, ARRAY_LEN(sensorList1), BSEC_SAMPLE_RATE_LP, sensorList2, ARRAY_LEN(sensorList2),BSEC_SAMPLE_RATE_SCAN))     //BSEC_SAMPLE_RATE_SCAN was default
    //if (!envSensor[i].updateSubscription(sensorList, ARRAY_LEN(sensorList), BSEC_SAMPLE_RATE_LP))
    {
    checkBsecStatus (envSensor[i]);
    }
     
    bsec2.cpp : override updateSubscription() to accept 6 params

    bool Bsec2::updateSubscription(bsecSensor sensorList1[], uint8_t nSensors1, float sampleRate1, bsecSensor sensorList2[], uint8_t nSensors2, float sampleRate2)
    {
    bsec_sensor_configuration_t virtualSensors[BSEC_NUMBER_OUTPUTS], sensorSettings[BSEC_MAX_PHYSICAL_SENSOR];
    uint8_t nSensorSettings = BSEC_MAX_PHYSICAL_SENSOR;

    for (uint8_t i = 0; i < nSensors1; i++)
    {
       virtualSensors[i].sensor_id = sensorList1[i];
       virtualSensors[i].sample_rate = sampleRate1;
    }

    for (uint8_t i = 0, j= nSensors1; i < nSensors2; i++)
    {
       virtualSensors[j].sensor_id = sensorList2[i];
       virtualSensors[j].sample_rate = sampleRate2;
    }

    /* Subscribe to library virtual sensors outputs */
    status = bsec_update_subscription_m(bsecInstance, virtualSensors, nSensors1+nSensors2, sensorSettings, &nSensorSettings);
    if (status != BSEC_OK)
           return false;

    return true;
    }

     

    bsec2.h : add prototype definition.

    bool updateSubscription(bsecSensor sensorList[], uint8_t nSensors, float sampleRate =
    BSEC_SAMPLE_RATE_ULP);

    bool updateSubscription(bsecSensor sensorList1[], uint8_t nSensors1, float sampleRate1, bsecSensor sensorList2[], uint8_t nSensors2, float sampleRate2);

    /dev/TTYUSB0 - output is captured here Screenshot from 2024-04-10 17-08-40.png

    BSTRobin
    Community Moderator
    Community Moderator

    Hi SunilS,

    Thanks for your inquiry.
    The current BSEC software architecture does not yet support the simultaneous use of IAQ and SCAN.
    You can refer to the supported virtual sensor output signals from BSEC integration if you have downloaded from https://www.bosch-sensortec.com/software-tools/software/bme688-software

    BSEC2.4.0.0 supported virtual sensor output signals.png

    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