Bosch Sensortec Community

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

    ESP8266 + BME68X_API_Library : Missing Heater Profile Steps

    ESP8266 + BME68X_API_Library : Missing Heater Profile Steps

    S_Brohl
    Established Member

    As the title suggests, I am working with a NodeMCU 12E ESP8266 microcontroller along with an Adafruit BME688  breakout board using the BME68X API Library. Everything appears to work just fine at first with this setup except over time I have some serious data dropouts (missing heater profile steps) that I cannot seem to find a solution for. It appears to me that over the span of a few hours with the setup running the timing between heater profile steps appears to become out of sync and measurements are lost as a result.

    I'm using the parallel_mode.ino sketch from the BME68X API Library untouched and I've tried using three different ESP8266 boards, two of which were brand new. I also tried changing the communication protocol from SPI to I2C in the example code, which the sensor could be read, but immediately I saw the same dropouts as with the SPI implementation.

    I've also tried using BSEC2 on another board just to see if the same thing could be observed, but it appears not to be the case. With the BSEC2 implementation everything works perfectly, however, this is not the implementation I'd like to use for my project. I simply want to use the API and get gas resistance along with TPH. I don't need any of the other overhead associated with BSEC2.

    Now at the time of writing this post I have setup two boards side-by-side. One with BSEC2 and one without BSEC in order to test and compare their outputs. Still I see these dropouts on the non-BSEC board using the default code, so  I've modified the heater profile to use HP 413 just to see what would happen. Still it's missing data! I also modified the example sketch again after seeing these dropouts so that I could write the data to an SD card over SPI, I will add the code for that below. Even with writing to the SD Card instead of the Serial monitor I saw these dropouts.

    Here is how I modified the heater profile:

    /* Heater temperature in degree Celsius */
    /*Default Profile 354: 320, 100, 100, 100, 200, 200, 200, 320, 320, 320*/
    uint16_t tempProf[10] = { 70, 350, 163, 350, 256, 256, 256, 350, 350, 350 };

    /* Multiplier for the heater profile duration steps */
    /*
    * Default shared heater profile multiplier for 354: 5, 2, 10, 30, 5, 5, 5, 5, 5, 5
    * ex:
    * (MEAS_DUR / 1000) x mulProf[0] = .7s
    * (MEAS_DUR / 1000) x mulProf[1] = .98s
    * (MEAS_DUR / 1000) x mulProf[2] = 2.38s
    *
    * HP 413:
    * uint16_t mulProf[10] = { 43, 2, 43, 2, 2, 20, 21, 2, 20, 21 };
    */
    uint16_t mulProf[10] = { 43, 2, 43, 2, 2, 20, 21, 2, 20, 21 };

    ^^ This was all I changed in the API code originally after noticing dropouts with HP354 (default profile) ^^

    Here are the modifications I made to the main loop so that data is written to an SD Card. I've also modified the logic a bit to use millis() for the delay between measurments instead of the delay(MEAS_DUR). I made this millis() change on the default code prior to the SD Card being implemented and still saw data dropouts, and again after implementing the SD card, so it appears this problem persists no matter what I do.

    void loop(void)
    {
    bme68xData data;
    uint8_t nFieldsLeft = 0;
    BmeTestDataFile2Write = SD.open(bmeFilename, FILE_WRITE);

    if (BMEheader) {
    // Create a CSV header for BME688 test data
    BmeTestDataFile2Write.println("HP413_BME68x_API");
    BmeTestDataFile2Write.println("Time,Temp,P,RH,R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,status");
    BMEheader = false;
    }

    if ((millis() - lastLogged) >= MEAS_DUR)
    {
    lastLogged = millis();
    if (bme.fetchData())
    {
    do
    {
    nFieldsLeft = bme.getData(data);
    if (data.status == NEW_GAS_MEAS)
    {
    /*
    Serial.print("HP_Step = ");
    Serial.println(data.gas_index);
    */
    // Print time, temp, pressure,- and humidity to file on heater profile step index 0
    if (data.gas_index == 0)
    {
    BmeTestDataFile2Write.print(String(rtc.now().unixtime()) + "," + String(data.temperature) + "," + String(data.pressure) + "," + String(data.humidity) + ",");
    }
    // Print gas resistance to file
    BmeTestDataFile2Write.print(String(data.gas_resistance) + ",");
    //Serial.print(String(data.gas_index) + ",");

    // on step index 9, print sensor status to file
    if (data.gas_index == 9)
    {
    BmeTestDataFile2Write.println(String(data.status, HEX));
    //Serial.println();
    }
    }
    } while (nFieldsLeft);
    BmeTestDataFile2Write.close();
    }
    }
    }

     


    Here are a few snippets of my data so you can see what I'm talking about.

    This is what the beginning of my data looks like:

    good_data.PNG

    All looks good to begin with....

    But then after a few hours of running I start to see this:bad_data.PNG

    It appears I either lose Heater profile step 0, or I lose multiple steps, but never a whole scan cycle.

    I'm really not sure why this is happening unless this MCU is not recommended for use with this library (but it compiled just fine) and there are plenty of guides which suggest this MCU works with both the BME680 and 688. 

    So just to recap:

    The default parallel_mode.ino code on an ESP8266 with a BME688 configured in SPI experiences dropouts in heater profile steps during scan measurments overtime. Changing the code/sensor to use i2c, experiences the same issue, but worse, and the same behavior is observed in every other change made to the code/hardware.

    Has anyone else seen anything like this before? Any help would be greatly appreciated!

    Note: I can share the setup() code that adds the SD Card if need-be, but as I had mentioned I see these dropouts regardless if there are other peripherals attached to the ESP8266 or not.

    4 REPLIES 4

    BSTRobin
    Community Moderator
    Community Moderator

    Hi S_Brohl,

    If you run your code with BSEC2, you should use https://github.com/boschsensortec/Bosch-BSEC2-Library, not use https://github.com/boschsensortec/Bosch-BME68x-Library as it is library for BSEC1.

    S_Brohl
    Established Member

    Hi Robin,

    Thank you for your quick response!

    As I mentioned I have two boards setup at the moment. One in which I'd like to use BSEC2 to collect data (which already works) and the other which does not use BSEC2 (Just the sensor API). The board without BSEC2 in which I am just using the API is the one causing the issues with missing data. 

    Are you suggesting I use BSEC2, but then only use the API from there, or are you just telling me to use BSEC2 in general? The current goal of my testing is to compare data from a sensor using BSEC2 and another one using only the sensor API, so ultimately I do not want to use BSEC2 on both boards for comparison.

     

    S_Brohl
    Established Member

    Hi BSTRobin,

    Could you please answer my previous response?  I am not using the BME68X API with BSEC1 or BSEC2, I am using it on it's own.

    You provided a different answer here which would suggest the BME68X API can be used regardless of BSEC1 or BSEC2.
    I also went to the BME688 software page and found the BME68X API download is shown there right next to the BSEC 2.0 download link, which would also suggest your  response was not accurate.

    bmeAPI.PNG

    S_Brohl
    Established Member

    Hi BSTRobin,

    Could you please answer my questions? I am currently stuck at a stand-still in my data collection and development until I have an answer.

    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