Bosch Sensortec Community

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

    BSEC v1.8.1492 not working with BME680

    BSEC v1.8.1492 not working with BME680

    rezza
    Member

    Helllo,

    I am trying to use BSEC v1.8.1492 driving a BME680 sensor using ESP32 chip, I am using Arduino framework and PlatfotmIO.

    Previously I used BSEC Software Library v1.6.1480 and everything worked smoothly but I couldn't make it work after updating the BSEC to the latest version (1.8.xxxx).

    I basically used the official example in github 

    https://github.com/boschsensortec/BSEC-Arduino-library/blob/master/examples/basic_config_state/basic...

    So basically iaqSensor.run() is always false but it seems to work once I commented iaqSensor.setConfig(bsec_config_iaq);

    and here is the actual code I am using 

     

    #include <bsec.h>
    #include <Wire.h>
    #include <Arduino.h>
    
    const uint8_t bsec_config_iaq[] = {
    #include "config/generic_33v_3s_4d/bsec_iaq.txt"
    };
    #define SERIAL_BAUDRATE 115200
    #define EEPROM_SIZE 512
    #define VERBOSE true
    #define DEVICE_NAME "Connected Ambiente"
    
    //* I2C Pins
    #define I2C_SDA_PIN GPIO_NUM_13
    #define I2C_SCL_PIN GPIO_NUM_15
    #define OLED_Address 0x3c
    #define I2C_Frequency 400000
    
    void checkIaqSensorStatus();
    
    Bsec iaqSensor;
    bsec_virtual_sensor_t sensorList[13] = {
        BSEC_OUTPUT_IAQ,
        BSEC_OUTPUT_STATIC_IAQ,
        BSEC_OUTPUT_CO2_EQUIVALENT,
        BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
        BSEC_OUTPUT_RAW_TEMPERATURE,
        BSEC_OUTPUT_RAW_PRESSURE,
        BSEC_OUTPUT_RAW_HUMIDITY,
        BSEC_OUTPUT_RAW_GAS,
        BSEC_OUTPUT_STABILIZATION_STATUS,
        BSEC_OUTPUT_RUN_IN_STATUS,
        BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
        BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
        BSEC_OUTPUT_GAS_PERCENTAGE};
    
    void setup()
    {
      Serial.begin(SERIAL_BAUDRATE);
    
      Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN, (uint32_t)I2C_Frequency);
    
      iaqSensor.begin(BME68X_I2C_ADDR_LOW, Wire);
      if (iaqSensor.bme68xStatus != 0)
      {
        iaqSensor.begin(BME68X_I2C_ADDR_HIGH, Wire);
        if (iaqSensor.bme68xStatus != 0)
        {
          printf("No sensor found.\r\n");
          return;
        }
        else
          printf("BME680 sensor found with secondary address.\r\n");
      }
      else
        printf("BME680 sensor found with primary address.\r\n");
    
      checkIaqSensorStatus();
    
      iaqSensor.updateSubscription(sensorList, 13, BSEC_SAMPLE_RATE_LP);
    
      iaqSensor.setConfig(bsec_config_iaq);
      checkIaqSensorStatus();
      printf(">> Sensor : BSEC library version %d.%d.%d.%d\r\n",
             iaqSensor.version.major,
             iaqSensor.version.minor,
             iaqSensor.version.major_bugfix,
             iaqSensor.version.minor_bugfix);
    }
    
    void loop()
    {
      // put your main code here, to run repeatedly:
      delay(100);
      unsigned long time_trigger = millis();
      if (iaqSensor.run())
      { // If new data is available
    
        String output = String(time_trigger);
        output += ", iaq: " + String(iaqSensor.iaq);
        output += ", iaqAccuracy: " + String(iaqSensor.iaqAccuracy);
        output += ", staticIaq: " + String(iaqSensor.staticIaq);
        output += ", co2Equivalent: " + String(iaqSensor.co2Equivalent);
        output += ", breathVocEquivalent: " + String(iaqSensor.breathVocEquivalent);
        output += ", rawTemperature: " + String(iaqSensor.rawTemperature);
        output += ", temperature: " + String(iaqSensor.temperature);
        output += ", " + String(iaqSensor.pressure);
        output += ", rawHumidity: " + String(iaqSensor.rawHumidity);
        output += ", humidity: " + String(iaqSensor.humidity);
        output += ", gasResistance: " + String(iaqSensor.gasResistance);
        output += ", stabStatus: " + String(iaqSensor.stabStatus);
        output += ", runInStatus: " + String(iaqSensor.runInStatus);
        output += ", gasPercentage: " + String(iaqSensor.gasPercentage);
        Serial.println(output);
      }
      else
      {
        checkIaqSensorStatus();
      }
    }
    
    void checkIaqSensorStatus(void)
    {
      if (iaqSensor.bsecStatus != BSEC_OK)
      {
        if (iaqSensor.bsecStatus < BSEC_OK)
        {
          printf("BSEC error code : %d\r\n", iaqSensor.bsecStatus);
          for (;;)
            ; /* Halt in case of failure */
        }
        else
        {
          printf("BSEC warning code : %d\r\n", iaqSensor.bsecStatus);
        }
      }
    
      if (iaqSensor.bme68xStatus != BME68X_OK)
      {
        if (iaqSensor.bme68xStatus < BME68X_OK)
        {
          printf("BME68X error code : %d\r\n", iaqSensor.bme68xStatus);
          for (;;)
            ; /* Halt in case of failure */
        }
        else
        {
          printf("BME68X warning code : %d\r\n", iaqSensor.bme68xStatus);
        }
      }
    }

     

    4 REPLIES 4

    BSTRobin
    Community Moderator
    Community Moderator

    Hi rezza,

    We recommend you to use latest library(BSEC2.4.0.0), you can dowload it from https://www.bosch-sensortec.com/software-tools/software/bme688-software

    BSTRobin
    Community Moderator
    Community Moderator

    Hi rezza,

    If you download BSEC2.4.0.0, you can also use latest API, example code, bsec.cpp in the software package.

    Thank you for your reply.

    I basically downloaded the latest library(BSEC2.4.0.0), I now I am running under v2.4.0.4. But I am experiencing the same issue.

    As I mentioned above, in latest version iaqSensor.run() is always false but it seems to work once I comment iaqSensor.setConfig(bsec_config_iaq);

    I attached the bsec.cpp file, I am using atm.

    BSTRobin
    Community Moderator
    Community Moderator

    Hi rezza,

    bsec.cpp was not contained in BSEC2.4.0.0. As you downloaed BSEC2.4.0.0, please use the example code under BSEC2.4.0.0 package.

    2023-07-03_14h12_35.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