Bosch Sensortec Community

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

    IAQ value not updating (BME688, BSEC2.0)

    BSTRobin
    Community Moderator

    Re: IAQ value not updating (BME688, BSEC2.0)

    Hello MightyNate,

    Coul we know detailed software you used? Original code, and your modification.

    EmiQS
    Member

    Re: IAQ value not updating (BME688, BSEC2.0)

    Helllo. I'm having this exact problem with BME688 & BSEC2.0 .

    Migrated my code from BSEC 1.4 to BSEC 2.0 (ESP32 board) and now IAQ Accuracy is always 0.

    I'm using  "BSEC_SAMPLE_RATE_HIGH_PERFORMANCE".

    And in "setConfig" I'm using BSEC provided configuration file "bsec_serialized_configurations_iaq.h"

    I was wondering... In BSEC 1.4 I used a configurating file (generic_33v_3s_4d) which configured, among other things (I guess), the sample rate (lp), the sensor voltage (3.3v) and sensor history (4days). Those configurations are not needed in BSEC 2.0 or it's supposed they're included in bsec_serialized_configurations.h?

    I'm also having problems when try to use BSEC 2.0 in any other mode than HIGH_PERFORMANCE. For example, if I change the sample rate to BSEC_SAMPLE_RATE_LP as I was using with BSEC 1.4, I got the following error: BSEC error code : -12. Which according to bsec_datatypes.h means:

    "The sample_rate of the requested output (virtual) sensor passed to bsec_update_subscription() does not match with the sampling rate allowed for that sensor"

     

    Thanks!

    alex_medina
    New Poster

    Re: IAQ value not updating (BME688, BSEC2.0)

    Hello.


    I am using the

    1. BME688 Sensor
    2. BME68x API downloaded form: https://github.com/BoschSensortec/BME68x-Sensor-API
    3. BSEC library Version 2.0.6.1 downloaded from: https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme688/
    4. using the esp32 huzzah32 as the electronics base
    5. I have a custom board, similar to the BME688 Shuttle Board, with 8 BME688 sensors on the PCB. I am using SPI to communicating with only 1 sensor for now.

    It seems that:

    a) SPI communications drivers work well,
    b) BME68x API works well to read/write BME688 sensor registers, set modes and retrieve measurement data.
    c) BSEC library was successfully integrated into the firmware source code.

    After Hardware initialization, BME68x API and BSEC library configuration and init successfully, I call bsec_sensor_control on a loop without any timing delay. I see that every 35 milliseconds the (curr_time_ns >= bsec_bme_settings.next_call) condition is accomplished. So it means that bsec_sensor_control function is exactly called every 35 milliseconds on the firmware.

    On the very first bsec_sensor_control call, the Parallel Mode is set to the BME688 sensor.

    989 milliseconds after the Parallel Mode is set, a bsec_bme_settings.trigger_measurement condition is accomplished and the bme68x_get_data function is called to read data from sensor.

    In this case only Temperature, Pressure, Humidity, Gas resistance and Gas index is gotten from the BSEC library and printed as follows:

    timestamp bsec [ns] = 4027000000
    timestamp [ns] = 4027000000
    #### bsec_do_steps returned 0
    Temperature = 27.568842
    Pressure = 73798.656250
    Humidity = 48.260582
    Gas resistance = 39421.003906
    Gas index = 0.000000


    280 milliseconds after again bsec_bme_settings.trigger_measurement condition is accomplished and the bme68x_get_data function is called to read data from sensor and again only Temperature, Pressure, Humidity, Gas resistance and Gas index is gotten from the BSEC library and printed as follows:

    timestamp bsec [ns] = 4307000000
    timestamp [ns] = 4307000000
    #### bsec_do_steps returned 0
    Temperature = 27.365967
    Pressure = 73800.343750
    Humidity = 48.222721
    Gas resistance = 1254517
    Gas index = 1.000000


    This condition repeats for different time periods. 1,365 milliseconds, 4,165 milliseconds, 700 milliseconds, ...... You can see the LOG file I attached to better understand

    And on the millisecond 14002 (current_time [ms] = 14002 equals to next_call [ms]: 14002) the BSEC library issues a bsec_bme_settings.trigger_measurement condition and bme68x_get_data function is called to read data from sensor.

    But at this time different variables are processed and printed out as follows:

    current_time [ms] = 14002, next_call [ms]: 14002
    timestamp bsec [ns] = 14002000000
    timestamp [ns] = 14002000000
    #### bsec_do_steps returned 0
    IAQ = 25.000000
    IAQ accuracy = 0
    Co2 Equivalent = 500.000000
    Breathe VOC Equivalent = 0.500000
    Temperature = 28.608572
    Pressure = 73786.507812
    Humidity = 45.241417
    Gas resistance = 80553.804688
    Stabilization status = 1.000000
    Run in status = 0.000000
    Compensated temperature = 25.608572
    Compensated humidity = 53.947281
    Gas Estimate 1 = 0.250000
    Gas Estimate 1 accuracy = 3
    Gas Estimate 2 = 0.250000
    Gas Estimate 2 accuracy = 3
    Gas Estimate 3 = 0.250000
    Gas Estimate 3 accuracy = 3
    Gas Estimate 4 = 0.250000
    Gas Estimate 4 accuracy = 3
    Gas index = 9.000000

    I see Compensated temperature, Compensated humidity are pretty similar to environment.

    I calculate Air Pressure by mysel from: Pressure at sea Level: 101,325 Pa, Ambient Temperature at 25.6°C, Aproximate Altitude over sea level at I am 2700 m
    and the calculation result is: 73,709.93 Pa, which is similar to the Pressure = 73,786.507812 printed out by the Firmware.

    I could say that the environment measurements from BME688 are close to reality.

    So far, so good!!!

    But, I am facing similar problems with IAQ value (25) and Accuracy (0). They are not changing even after several minutes executing the firmware.

    I don't really know too if Gas resistance, stabilization, Gas Estimate 1,2,3,4 and Gas Estimate accuracy 1,2,3,4 are good.


    I attach the source code I am using.

     

    The bsec_integration.c .h have all fuctions called by the firmware and they have the same logic and function calls on the Bosch BSEC library example folder (bsec.c .h source code), but in this case is on C language.

    I found these implementation source code on C language from:

    https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/Not-able-to-get-Gas-Estimate-Channel-X-f...


    Can you see any timing anomaly or do you think it could be timing on lower SPI communication level?

     

     

    Thank you and my best regards

    alex_medina
    New Poster

    Re: IAQ value not updating (BME688, BSEC2.0)

    I changed the sample rate from BSEC_SAMPLE_RATE_HIGH_PERFORMANCE to BSEC_SAMPLE_RATE_LP for the virtual sensors in the bsec_update_subscription function call.

    With this new configuration an error with code -12 occurs when calling bsec_update_subscription:

    BSEC_E_SU_SAMPLERATELIMITS = -12, /*!< The sample_rate of the requested output (virtual) sensor passed to bsec_update_subscription() does not match with the sampling rate allowed for that sensor */

    Checking the BSEC Integration Guidelines documentation (1.2.4 Supported Virtual Sensor Output Signals), I see that BSEC_OUTPUT_RAW_GAS_INDEX and  BSEC_OUTPUT_GAS_ESTIMATE_1 to _4 have a sample rate of SEL (1/300, 1/3, 1, 1/heater step duration, 1/scan duration)Hz respectively. So I removed those virtual sensors from the the bsec_update_subscription requested_virtual_sensir list for now.

     

     

    After the firmware initializes correctly, (curr_time_ns >= bsec_bme_settings.next_call) condition is satisfied every 3 seconds exactly and then bsec_sensor_control function is called every 3 seconds exactly, and the sensor is set into FORCED Mode operation.

    In this BSEC_SAMPLE_RATE_LP configuration now I can see IAQ, Co2 Equivalent and Breath VOC Equivalent values being changing, with measurements every 3 seconds:

    next_call [ns]: 2994030000000 --------->This mean that next bsec_sensor_control call must be at this nanosecond
    current_time [ns] = 2994030000000, this_call [ns]: 2994030000000 -------> This mean that current time and next time are equals, no time lag, bsec_sensor_control will be executed rigth now
    ####Setting FORCED Mode
    timestamp bsec [ns] = 2994030000000
    timestamp [ns] = 2994030000000
    #### bsec_do_steps returned 0
    *****************************
    IAQ = 100.527153, accuracy = 1
    Static IAQ = 57.992462, accuracy = 1
    Co2 Equivalent = 631.969849, accuracy = 1
    Breathe VOC Equivalent = 0.823313, accuracy = 1
    Temperature = 25.753147
    Pressure = 73262.335938
    Humidity = 37.276054
    Gas resistance = 51800.890625
    Stabilization status = 1.000000
    Run in status = 1.000000
    Heat Compensated temperature = 25.688456
    Heat Compensated humidity = 37.406696
    Gas percentage = 34.426498
    *****************************
    next_call [ns]: 2997030000000
    current_time [ns] = 2997030000000, this_call [ns]: 2997030000000
    ####Setting FORCED Mode
    timestamp bsec [ns] = 2997030000000
    timestamp [ns] = 2997030000000
    #### bsec_do_steps returned 0
    *****************************
    IAQ = 101.312813, accuracy = 1
    Static IAQ = 58.335663, accuracy = 1
    Co2 Equivalent = 633.342651, accuracy = 1
    Breathe VOC Equivalent = 0.827595, accuracy = 1
    Temperature = 25.748074
    Pressure = 73262.609375
    Humidity = 37.264271
    Gas resistance = 52021.945312
    Stabilization status = 1.000000
    Run in status = 1.000000
    Heat Compensated temperature = 25.683382
    Heat Compensated humidity = 37.406395
    Gas percentage = 34.776802
    *****************************
    next_call [ns]: 3000030000000
    current_time [ns] = 3000030000000, this_call [ns]: 3000030000000
    ####Setting FORCED Mode
    timestamp bsec [ns] = 3000030000000
    timestamp [ns] = 3000030000000
    #### bsec_do_steps returned 0
    *****************************
    IAQ = 101.402786, accuracy = 1
    Static IAQ = 58.374962, accuracy = 1
    Co2 Equivalent = 633.499878, accuracy = 1
    Breathe VOC Equivalent = 0.828087, accuracy = 1
    Temperature = 25.753147
    Pressure = 73263.554688
    Humidity = 37.270420
    Gas resistance = 52085.453125
    Stabilization status = 1.000000
    Run in status = 1.000000
    Heat Compensated temperature = 25.688456
    Heat Compensated humidity = 37.403931
    Gas percentage = 34.817921
    *****************************
    next_call [ns]: 3003030000000
    current_time [ns] = 3003030000000, this_call [ns]: 3003030000000
    ####Setting FORCED Mode
    timestamp bsec [ns] = 3003030000000
    timestamp [ns] = 3003030000000
    #### bsec_do_steps returned 0
    *****************************
    IAQ = 97.066452, accuracy = 1
    Static IAQ = 56.480728, accuracy = 1
    Co2 Equivalent = 625.922913, accuracy = 1
    Breathe VOC Equivalent = 0.804712, accuracy = 1
    Temperature = 25.753147
    Pressure = 73263.554688
    Humidity = 37.259148
    Gas resistance = 52729.144531
    Stabilization status = 1.000000
    Run in status = 1.000000
    Heat Compensated temperature = 25.688456
    Heat Compensated humidity = 37.394669
    Gas percentage = 32.891785
    *****************************
    next_call [ns]: 3006030000000

     

    So here my questions:

     

    What is the difference between BSEC_SAMPLE_RATE_HIGH_PERFORMANCE and BSEC_SAMPLE_RATE_LP for the virtual sensors in the bsec_update_subscription function call?

    What could be the reason why in BSEC_SAMPLE_RATE_HIGH_PERFORMANCE cannot see IAQ values?

    In BSEC_SAMPLE_RATE_LP, How can I calibrate the sensor, since the accuracy flag is 1 (meaning that sensor needs to be calibrated)?

    Thank you and regards.

     

    Alejandro Medina

     

    Alejandro Medina

    BSTRobin
    Community Moderator

    Re: IAQ value not updating (BME688, BSEC2.0)

    For BSEC1 and BSEC2, the example code are totally different, you should strictly use the example code in bsec2 release package. The config string in bsec_serialized_configurations_selectivity.h and bsec_serialized_configurations_selectivity.c shall be used instead of bsec_serialized_configurations_iaq.

    BSEC_SAMPLE_RATE_HIGH_PERFORMANCE and BSEC_SAMPLE_RATE_LP is just different in HZ setting. You can have a check on bsec_datatypes.h.

    Please follow the example code in BSEC2 release package strictly then we can see if the issue can be fixed or not.

    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