Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Running BME680 + BSEC2, STATIC_IAQ accuracy always 1

    Running BME680 + BSEC2, STATIC_IAQ accuracy always 1

    shadowpho
    New Poster

    I am using the latest version of BSEC2.0.61, with BME680 on a raspberry pi zero w. I am using BME68x c interface (from github) and feed the data into BSEC per request (I use timing from next_call), on LP speed.

    I am using the bsec_config_iaq from bsec_serialized_configurations_iaq.c for bsec_set_configuration.

    There are no erros from any BME or BSEC calls. BME680 gets reset and passes self-test on every start.

    However the issue is that STATIC_IAQ accuracy never rises above 1.  It goes from 0->1 in about 5 minutes and stays there for at least a day.  I feed 5 sensors into do_steps:  temperature, heat_source (0.3c), humidity,pressure and gas_resistance.   I verified that temperature, humidity, pressure are all valid (even though accuracy of them always stays at 0?). I have 4 other sensors in this device and they all report nearly identical values for temp, humidity and pressure.

    The source code is available here, with link pointing towards my "glue" file: https://github.com/shadowpho/OutsideSensor/blob/master/BSECglue.cpp

    The whole BSEC_BME runs in it's own thread.  Here is the thread (from main.cpp). As you can see we run the init, then run the loop as needed (and add the output to mutex-protected storage space if it's valid).

    void BME680_loop(CMA_Data* obj, CMA_Data* obj2)
    {
      BSEC_BME_init();
      float temp, pressure, humidity, VOC;
      while (1) {
        int ret = BSEC_BME_loop(&temp, &pressure, &humidity, &VOC);
        if (ret != 0) { printf("BME/BSEC LOOP FAIL!!! %i\n", ret); }
        if (!std::isnan(temp)) add_to_CMA(obj, temp, pressure, humidity, 0);
        if (!std::isnan(VOC)) add_to_CMA(obj2, VOC, 0, 0, 0);
        sleep_us(BSEC_desired_sleep_us());
      }
    }

     

    How can I debug this? What am I doing wrong with it?

    How can I debug?  It's a bit painful because there are no good examples for raspberry pi.

    6 REPLIES 6

    BSTRobin
    Community Moderator
    Community Moderator

    Hi shadowpho,

    You could use all the code under "BSEC_2.0.6.1_Generic_Release_04302021\examples", run with example code and record log data for check.

    Hello BSTRobin!

    The example code is .ino arduino. It does not run on raspberry pi.


    What kind of log are you looking for? I have plenty of logs for BME680: the temperature/humidity/pressure are all correct, it's only IAQ or static IAQ that does not settle

    Here is log from yesterday.  It prints out Sensor output and accuracy.

    2:25.00,acc:0
    7:101964.24,acc:0
    14:30.40,acc:0
    15:28.63,acc:0

    As you can see pressure 7, temp 14, humidity 15, and IAQ is 2.  IAQ eventually goes to 100, but never gets to accuracy 2

    BSTRobin
    Community Moderator
    Community Moderator

    Hi shadowpho,

    If you run example "examples\bsec2\examples\basic_config_state\basic_config_state.ino", you will see output log from the folloing function.

    void bsecCallback(const bme68x_data& input, const BsecOutput& outputs)

    {

      if (!outputs.len)

        return;

       

      Serial.println("BSEC outputs:\n\ttimestamp = " + String((int)(outputs.outputs[0].time_stamp / INT64_C(1000000))));

      for (uint8_t i = 0; i < outputs.len; i++) {

        const bsec_output_t& output = outputs.outputs[i];

        switch (output.sensor_id) {

          case BSEC_OUTPUT_IAQ:

            Serial.println("\tiaq = " + String(output.signal));

            Serial.println("\tiaq accuracy = " + String((int)output.accuracy));

            break;

          case BSEC_OUTPUT_RAW_TEMPERATURE:

            Serial.println("\ttemperature = " + String(output.signal));

            break;

          case BSEC_OUTPUT_RAW_PRESSURE:

            Serial.println("\tpressure = " + String(output.signal));

            break;

          case BSEC_OUTPUT_RAW_HUMIDITY:

            Serial.println("\thumidity = " + String(output.signal));

            break;

          case BSEC_OUTPUT_RAW_GAS:

            Serial.println("\tgas resistance = " + String(output.signal));

            break;

                  case BSEC_OUTPUT_RAW_GAS_INDEX:

            Serial.println("\tgas index = " + String(output.signal));

            break;

          case BSEC_OUTPUT_STABILIZATION_STATUS:

            Serial.println("\tstabilization status = " + String(output.signal));

            break;

          case BSEC_OUTPUT_RUN_IN_STATUS:

            Serial.println("\trun in status = " + String(output.signal));

            break;

          case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE:

            Serial.println("\tcompensated temperature = " + String(output.signal));

            break;

          case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY:

            Serial.println("\tcompensated humidity = " + String(output.signal));

            break;

          case BSEC_OUTPUT_GAS_ESTIMATE_1:

          case BSEC_OUTPUT_GAS_ESTIMATE_2:

          case BSEC_OUTPUT_GAS_ESTIMATE_3:

          case BSEC_OUTPUT_GAS_ESTIMATE_4:

            Serial.println("\tgas estimate " + String((int)(output.sensor_id + 1 - BSEC_OUTPUT_GAS_ESTIMATE_1)) + String(" = ") + String(output.signal));

            break;

          default:

            break;

        }

      }

    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