Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME688 Arduino recent example

    hugehead
    Member

    BME688 Arduino recent example

    Hello,

    I have purchased a BME688 breakout board and woudl like to run an Indoor Air Quality Example on Arduino ESP32. I do see different download options for BME688 Software. There are mentioned multiple times "Arduino Example" for BSEC 2.x Integration guide AND API integration Example.

    hugehead_0-1638276668064.png

    Another example "basic_config_state" is in BSEC 2.x Software package as "bsec".

     

    hugehead_1-1638276821055.png

     

    • Which example shall i use to run the BME688 on Arduino to get a proper IAQ value?

     

    I tried with bsec2 example "basic_config_state" on ESP32 with "bsec_serialized_configurations_iaq" and removed all EEPROM part which gives me an output like the following. It has values without IAQ until Gas_index = 9 appears. Please note, there is a time gap of 1:55 minute between iaq reading and new measurement.

    The example gives some measurements and then has a pause of ~2 minutes. Is that expected behavior?

    14:05:55.097 -> BSEC outputs:
    14:05:55.097 -> 	timestamp = 161860
    14:05:55.097 -> 	temperature = 27.94
    14:05:55.097 -> 	pressure = 97182.41
    14:05:55.097 -> 	humidity = 46.24
    14:05:55.097 -> 	gas resistance = 114746.75
    14:05:55.097 -> 	gas index = 0.00
    14:05:55.374 -> BSEC outputs:
    14:05:55.374 -> 	timestamp = 162140
    14:05:55.374 -> 	temperature = 28.18
    14:05:55.374 -> 	pressure = 97184.16
    14:05:55.374 -> 	humidity = 46.17
    14:05:55.374 -> 	gas resistance = 9183857.00
    14:05:55.374 -> 	gas index = 1.00
    14:05:56.752 -> BSEC outputs:
    14:05:56.752 -> 	timestamp = 163505
    14:05:56.752 -> 	temperature = 28.65
    14:05:56.752 -> 	pressure = 97181.55
    14:05:56.752 -> 	humidity = 45.17
    14:05:56.752 -> 	gas resistance = 8763841.00
    14:05:56.752 -> 	gas index = 2.00
    14:06:00.902 -> BSEC outputs:
    14:06:00.902 -> 	timestamp = 167670
    14:06:00.902 -> 	temperature = 29.60
    14:06:00.902 -> 	pressure = 97185.88
    14:06:00.902 -> 	humidity = 41.80
    14:06:00.902 -> 	gas resistance = 7777830.50
    14:06:00.902 -> 	gas index = 3.00
    14:06:01.620 -> BSEC outputs:
    14:06:01.620 -> 	timestamp = 168370
    14:06:01.620 -> 	temperature = 30.34
    14:06:01.620 -> 	pressure = 97184.32
    14:06:01.620 -> 	humidity = 41.39
    14:06:01.620 -> 	gas resistance = 603951.62
    14:06:01.620 -> 	gas index = 4.00
    14:06:02.312 -> BSEC outputs:
    14:06:02.312 -> 	timestamp = 169070
    14:06:02.312 -> 	temperature = 30.73
    14:06:02.312 -> 	pressure = 97186.54
    14:06:02.312 -> 	humidity = 40.90
    14:06:02.312 -> 	gas resistance = 579349.38
    14:06:02.312 -> 	gas index = 5.00
    14:06:03.023 -> BSEC outputs:
    14:06:03.023 -> 	timestamp = 169770
    14:06:03.023 -> 	temperature = 30.99
    14:06:03.023 -> 	pressure = 97192.75
    14:06:03.023 -> 	humidity = 40.49
    14:06:03.023 -> 	gas resistance = 556673.00
    14:06:03.023 -> 	gas index = 6.00
    14:06:03.732 -> BSEC outputs:
    14:06:03.732 -> 	timestamp = 170470
    14:06:03.732 -> 	temperature = 31.53
    14:06:03.732 -> 	pressure = 97188.94
    14:06:03.732 -> 	humidity = 39.87
    14:06:03.732 -> 	gas resistance = 137931.03
    14:06:03.732 -> 	gas index = 7.00
    14:06:04.375 -> BSEC outputs:
    14:06:04.375 -> 	timestamp = 171135
    14:06:04.375 -> 	temperature = 31.89
    14:06:04.375 -> 	pressure = 97187.52
    14:06:04.375 -> 	humidity = 39.34
    14:06:04.375 -> 	gas resistance = 177716.08
    14:06:04.375 -> 	gas index = 8.00
    14:06:05.104 -> BSEC outputs:
    14:06:05.104 -> 	timestamp = 171835
    14:06:05.104 -> 	iaq = 25.00
    14:06:05.104 -> 	iaq accuracy = 0
    14:06:05.104 -> 	temperature = 32.15
    14:06:05.104 -> 	pressure = 97189.34
    14:06:05.104 -> 	humidity = 38.76
    14:06:05.104 -> 	gas resistance = 214765.09
    14:06:05.104 -> 	compensated temperature = 29.15
    14:06:05.104 -> 	compensated humidity = 49.76
    14:06:05.104 -> 	gas estimate 1 = 0.25
    14:06:05.104 -> 	gas estimate 2 = 0.25
    14:06:05.104 -> 	gas estimate 3 = 0.25
    14:06:05.104 -> 	gas estimate 4 = 0.25
    14:06:05.104 -> 	gas index = 9.00

     

    Attached is my arduino exmaple code.

    Kind Regards

    Matthias

     

     

     

     

    Tags (2)
    9 REPLIES 9
    BSTRobin
    Community Moderator

    Re: BME688 Arduino recent example

    Hello hugehead ,

    You should use BSEC 2.x example if you want to output BSEC IAQ value.

    As you delete EEPROM part, BSEC config file willn't be loaded.

    hugehead
    Member

    Re: BME688 Arduino recent example

    Hello Robin,

    thank you very much for the answer. I was using the BSEC 2.x example, so this should be ok.

     

    • Question 1
    As you delete EEPROM part, BSEC config file willn't be loaded.

    Is that actually an issue? I read in the instructions somewhere to delete the EEPROM part, and it didnt work on my ESP32 anyway. I understood that the Sensor can save its state in there. If i restart my arduino, i will begin from scratch, right?

    • Question 2
      I did have another question regarding the outputs and timing of the BSEC 2.x example. I do get values for gas index 0-9 and with ne 9th index i get IAQ values. Is that the correct behavior?
      The timing is a little odd , i get some values regularly and from time to time it takes ~2 minutes for next measurement. I checked the xxx.next_call funtion return which is giving me actually a timestamp 2 minutes in the future. I am wondering if that is the correct behavior as well=
    • Question 3
      For IAQ measurements, do i have to change "bsec_config_selectivity" to "bsec_config_iaq", correct?

     

     

    hugehead
    Member

    Re: BME688 Arduino recent example

    Could you please answer to my questions?

    iamdjango
    Member

    Re: BME688 Arduino recent example

    Hi Hugehead,

    Since you're not getting much help from staff other than the usual can responses and because I really struggled getting the BME688 working in with the BSEC 2.0 lib the last few days, I thought I'd give you a hand 🙂

    I've come to the conclusion that BME688 is broken on BSEC 1.0 (the resistance never changes) despite what staff say on this forum and the Arduino interface for 2.0 is a massive step backwards vs the previous version with lots of missing functionality and only one example, hopefully a new release will fix this.

    Regarding your questions:

    Question 1: This is an issue for two reasons, the first is that I'm not sure what the expected behaviour of the lib is if you do provide a variable to store state and each time you reset your device BSEC 2 needs to recalibrate (monitor a stable clean environment then a dirty one i.e. your breath in a box) from scratch to get accuracy 3 which takes a long time. A simple fix would be to pass a global to setState.

    uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
    ...

    bsec.setState(bsecState);

    Question2:

    Good question, this did my head in for some time too. Yes this is, the single example file they provide is for use with the BSEC 2.0 AI gas training program (that i have not used) which heats up the detector several times to different temps to detect different gases. If you would like the basic IAQ/COeq/VOCeq functionality as per BSEC 1.0 you have to specify the following sensors only:

    bsec_virtual_sensor_t sensorList[] = {
    BSEC_OUTPUT_RAW_TEMPERATURE,
    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
    };

    I figured that out by trail and error 😕 If BSEC_OUTPUT_RAW_GAS_INDEX, or BSEC_OUTPUT_GAS_ESTIMATE_* are included then you'll get the random pauses you talked about as the heater is heated multiple times and cooled for each gas index, which is probably all junk output anyway as I think you need to run their AI tool to train a new config file. This still has one problem in that you don't get any readings the first time you call bsecInst.run(), unlike with the previous version, which is a issue if you plan to deep sleep your device.

    Question 3:

    I ignored the bsec_serialized_* header files in the src directory of the library has I couldnt find any info on what these are actually configuring for. Instead I copied in the config directory from the BSEC 2.0 download into the root directory of the lib I created for 2.0 and then use the same named config as in BSEC 1.0 examples for LP mode: generic_33v_3s_4d and generic_33v_300s_4d for ULP mode:

    #include "../config/generic_33v_3s_4d/bsec_serialized_configurations_selectivity.h"

    Hopefully that helps. I can provide you with my .ino if you like but it probably won't work for you directly as I've already made several changes/fixes to bsec.h/.cpp to get deep sleep working.

    Cheers,

    Tags (1)
    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