Bosch Sensortec Community

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

    I2C BME688 0x77 on Arduino MKR Zero: custom heater profile and gas resistant logging.

    I2C BME688 0x77 on Arduino MKR Zero: custom heater profile and gas resistant logging.

    DN_LiU
    New Poster

    Hi,

    We have a project to study gas emission from cooking activity in a tropical country, to determine its affect on women health. We would like to try the gas scan function of the BME688s to find the VOCs "fingerprint" when people use different fuel materials (as cow dung, wood, kerosel, etc) and the cooking foods. For this purpose of trying to distinguish gases emission from cooking activities at different areas, after reading on this forum and some publications, I think about applying a heater profile and log as much data as posible. We have a 32 GB SD card. I use "bme68xLibrary.h"

    // /* Heater temperature in degree Celsius */

    uint16_t tempProf[22] = {400, 100, 400, 125, 400, 150, 400, 175, 400, 200, 400, 250, 400, 275, 400, 300,400, 325, 400, 350, 400, 375};

    // /* Heating duration in millismillisseconds */

    uint16_t durProf[22] = { 5000, 7000, 5000, 7000,5000, 7000, 5000, 7000, 5000,7000,5000,7000, 5000,7000,5000,7000,5000,7000,5000,7000, 5000,7000};

    However, the MKR got frozen after run in the function bme.setHeaterProf(tempProf, durProf, 22);

    Then I tried with the force mode, 

    bme.setHeaterProf(temp, 5000); // Set the gas heater temperature and duration

    bme.setOpMode(BME68X_FORCED_MODE);
     

    It takes 4040 ms for bme.fetchData() == 1, and the bme.getData(data) only return a value of data.gas_resistance; the arduino code is in attachment. I wonder if there is a possibility to record all gas resistance values over the heater profile cycle.

    Thanks in advance. I really appreciate for all suggestion and recommendation.

     

    7 REPLIES 7

    BSTRobin
    Community Moderator
    Community Moderator

    Hi DN_LiU,

    If you define your own heater profile, you need to note that it supports up to 10 temperature steps. Your 22 temperature steps need to be changed to 10. Otherwise, the heater profile will not be executed correctly.

    Hi Robin, Thanks for your response, and to follow up, how can I log the gas resistance values at these 10 temperature steps? My code as below:

    void setup(void)
    {
    Wire.begin();
    Serial.begin(115200);
    while (!Serial)
     
    /* Initializes the sensor based on SPI library */
    bme.begin(BME68X_I2C_ADDR_HIGH, Wire);

    Serial.println("BME68x I2C 0x77 begin");
    /* Set the default configuration for temperature, pressure and humidity */
    bme.setTPH();
    /* Heater temperature in degree Celsius */
    uint16_t tempProf[10] = {400, 100, 150, 200, 250, 300, 325, 350, 375, 400};
    /* Heating duration in milliseconds */
    uint16_t durProf[10] = {1000, 1000, 1000, 1000, 1000,1000,1000,1000,1000,1000};
    // Uncomment below for sequential mode
    bme.setSeqSleep(BME68X_ODR_250_MS);
    Serial.println("Set SeqSleep");
    bme.setOpMode(BME68X_SEQUENTIAL_MODE);
    Serial.println("Set seq mode");
    bme.setHeaterProf(tempProf, durProf, 10);
    Serial.println("Done Set heatprofile");
    }
    void loop(void)
    {
    bme68xData data;
    uint8_t nFieldsLeft = 0;
    // BME68X_SEQUENTIAL_MODE
    delay(10000);
    if (bme.fetchData())
    {
    do
    {
    nFieldsLeft = bme.getData(data);
    //Serial.println(nFieldsLeft);
    //if (data.status == NEW_GAS_MEAS)
    {
    Serial.print(String(millis()) + ", ");
    Serial.print(String(nFieldsLeft) + ", ");
    Serial.print(String(data.temperature) + ", ");
    Serial.print(String(data.pressure) + ", ");
    Serial.print(String(data.humidity) + ", ");
    Serial.print(String(data.gas_resistance) + ", ");
    Serial.print(String(data.status, HEX) + ", ");
    Serial.println(data.gas_index);
    if(data.gas_index == 2) /* Sequential mode sleeps after this measurement */
    delay(250);
    }
    } while (nFieldsLeft);
    }
    }
     
    On my serial Monitor, there is only one resistance value showed up:
    BME68x I2C 0x77 begin
    Set SeqSleep
    Set seq mode
    Done Set heatprofile
    3146707, 0, 31.10, 100518.80, 31.89, 6400000.00, 80, 15
     
    Thanks in advance,

    BSTRobin
    Community Moderator
    Community Moderator

    Hi DN_LiU,

    For temperature, it's better to set from 200 to 400, and for duration, it's better from 30 to 4032ms.

    Thanks Robin for your recommendation. To be able to record the gas resistance value of your recommendation heater profile: 

    /* Heater temperature in degree Celsius */

    uint16_t tempProf[10] = {400, 200, 225, 250, 275, 300, 325, 350, 375, 400};

    /* Heating duration in milliseconds */
    uint16_t durProf[10] = {1000, 1000, 1000, 1000, 1000,1000,1000,1000,1000,1000};
     
    I have to use the FORCED_MODE as the following code:
     
    bme.setHeaterProf(400, 1000);
    bme.setOpMode(BME68X_FORCED_MODE);
    delayMicroseconds(bme.getMeasDur());
    if (bme.fetchData())
    {
    bme.getData(data);
    Serial.print(String(millis()) + ", ");
    Serial.print(String(data.temperature) + ", ");
    Serial.print(String(data.pressure) + ", ");
    Serial.print(String(data.humidity) + ", ");
    Serial.print(data.status, HEX);
    Serial.print(" 400C: ");
    Serial.print(String(data.gas_resistance) + ", ");
    }
    // BME68X_FORCED_MODE
    for (int temp = 175; temp <= 400; temp += 25) { // Temperature range from 200 to 400°C with 25°C steps
    startMillis = millis();
    bme.setHeaterProf(temp, 1000); // Set the gas heater temperature and duration
    bme.setOpMode(BME68X_FORCED_MODE);
    if (bme.fetchData()) {
    endMillis = millis();
    Serial.print(endMillis - startMillis);
    Serial.print(" ms ");
    Serial.print(temp);
    Serial.print("C: ");
    bme.getData(data);
    Serial.print(data.gas_resistance); // Convert gas resistance to kOhm
    Serial.print(", ");
    }
    }
    Serial.println();
    delay(10000);
    }
     
    The Serial Monitor is as following:
    24278, 33.04, 99813.79, 34.93, B0 400C: 126952.64, 936 ms 200C: 6863846.00, 1023 ms 225C: 2834602.00, 1033 ms 250C: 1507545.12, 1033 ms 275C: 821335.50, 1033 ms 300C: 472651.75, 1033 ms 325C: 256000.00, 1022 ms 350C: 156958.92, 1033 ms 375C: 114669.66, 1033 ms 400C: 101446.41, 
    43584, 33.08, 99813.24, 33.68, B0 400C: 129949.24, 936 ms 200C: 6991252.50, 1022 ms 225C: 2913229.00, 1033 ms 250C: 1528643.37, 1033 ms 275C: 820841.69, 1033 ms 300C: 469724.78, 1033 ms 325C: 251473.48, 1022 ms 350C: 154963.69, 1033 ms 375C: 112775.33, 1032 ms 400C: 97728.57, 
    62889, 33.13, 99814.62, 35.31, B0 400C: 123462.74, 936 ms 200C: 6574639.00, 1022 ms 225C: 2740716.00, 1033 ms 250C: 1444287.75, 1033 ms 275C: 802507.81, 1033 ms 300C: 463034.13, 1023 ms 325C: 251658.89, 1033 ms 350C: 156383.63, 1033 ms 375C: 114746.75, 1033 ms 400C: 101870.27, 
    82195, 33.13, 99814.91, 33.38, B0 400C: 131551.91, 935 ms 200C: 7620465.00, 1022 ms 225C: 3246285.00, 1033 ms 250C: 1681100.00, 1033 ms 275C: 911843.25, 1033 ms 300C: 519401.47, 1022 ms 325C: 277883.31, 1033 ms 350C: 168587.42, 1033 ms 375C: 121962.84, 1033 ms 400C: 106113.99, 
    101501, 33.14, 99812.82, 32.57, B0 400C: 134242.27, 935 ms 200C: 7884504.50, 1022 ms 225C: 3351882.25, 1033 ms 250C: 1724631.62, 1033 ms 275C: 927326.25, 1033 ms 300C: 532362.88, 1022 ms 325C: 281318.69, 1033 ms 350C: 171812.08, 1033 ms 375C: 122576.01, 1033 ms 400C: 106844.74, 
    120807, 33.12, 99814.49, 32.48, B0 400C: 135092.34, 936 ms 200C: 8059026.00, 1022 ms 225C: 3406237.00, 1033 ms 250C: 1753424.62, 1033 ms 275C: 958577.13, 1033 ms 300C: 544680.88, 1033 ms 325C: 288939.06, 1022 ms 350C: 174446.34, 1033 ms 375C: 125736.74, 1033 ms 400C: 108474.58, 
    140112, 33.10, 99815.96, 32.36, B0 400C: 135413.91, 936 ms 200C: 8241448.50, 1022 ms 225C: 3482253.00, 1033 ms 250C: 1791384.25, 1033 ms 275C: 974310.19, 1033 ms 300C: 553513.50, 1022 ms 325C: 294168.34, 1033 ms 350C: 177716.08, 1033 ms 375C: 127331.51, 1033 ms 400C: 109589.04, 
     
     
    Is it ok? I tried to use the SEQUENTIAL-MODE but I cannot extract the gas reristance value at each temperature steps. 
    Thanks in advance,
    Best regards,
     
    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