Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Incorrect BME688 Gas Resistance values

    Incorrect BME688 Gas Resistance values

    LinuxGuys
    New Poster

    HI BOSCH,

    We are using the already built driver for bme680 sensor from the Linux version 5.10. But we need bme688 so we compared the datasheet and got to know that T,P,H calculations and registers are same for both bme680 and bme688 .The only difference we noticed is Gas resistance registers and calculations,So according to the datasheet we modified those register values and calculations and tried integrating the sensor using BeagleBoneBlack board ,we are getting T,P,H same but gas resistance is getting increased gradually but when we keep a alcohol near to it is sensing and decreasing the resistance and after again it's starts increasing gradually .I am adding below what are the changes made .So, it will be help full to me if your team can check and give me any suggestion to how to solve it .

    //Registers i changed for gas resistance

    //BME680 to BME688

    #define BME680_REG_GAS_MSB 0x2A to 0x2C
    #define BME680_REG_GAS_R_LSB 0x2B to 0x2D
    #define BME680_GAS_STAB_BIT BIT(4) to BIT(5)

    #define BME680_RUN_GAS_MASK BIT(4) to BIT(5)

    //Actual code for BME680

    static u32 bme680_compensate_gas(struct bme680_data *data, u16 gas_res_adc,
    u8 gas_range)
    {
    struct bme680_calib *calib = &data->bme680;
    s64 var1;
    u64 var2;
    s64 var3;
    u32 calc_gas_res;

    /* Look up table for the possible gas range values */
    const u32 lookupTable[16] = {2147483647u, 2147483647u,
    2147483647u, 2147483647u, 2147483647u,
    2126008810u, 2147483647u, 2130303777u,
    2147483647u, 2147483647u, 2143188679u,
    2136746228u, 2147483647u, 2126008810u,
    2147483647u, 2147483647u};

    var1 = ((1340 + (5 * (s64) calib->range_sw_err)) *
    ((s64) lookupTable[gas_range])) >> 16;
    var2 = ((gas_res_adc << 15) - 16777216) + var1;
    var3 = ((125000 << (15 - gas_range)) * var1) >> 9;
    var3 += (var2 >> 1);
    calc_gas_res = div64_s64(var3, (s64) var2);

    return calc_gas_res;
    }

     

    //Calculations what i made according to BME688 from the datasheet

    static u32 bme680_compensate_gas(struct bme680_data *data, u16 gas_res_adc,
    u8 gas_range)
    {
    struct bme680_calib *calib = &data->bme680;
    u32 var1;
    u32 var2;
    u32 calc_gas_res;

    var1 = U32_C(262144) >> gas_range;
    var2 = gas_res_adc - S32_C(512);
    var2 *= S32_C(3);
    var2 = S32_C(4096) + var2;
    calc_gas_res = ((U32_C(10000) * var1) / var2) * 100;*/

    return calc_gas_res;
    }

    1 REPLY 1

    BSTRobin
    Community Moderator
    Community Moderator

    Hi LinuxGuys,

    The official BME68x sensor API has implemented how to obtain sensor data. You can refer to the sensor API and use it.
    https://github.com/boschsensortec/BME68x-Sensor-API

    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