Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Incorrect BME688 Gas Resistance values

    Incorrect BME688 Gas Resistance values

    New Poster


    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

    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.