0

We are using the already built driver for BME680 sensor from the Linux kernel v5.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 BeagleBone Black 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;
}

BME680 Readings

Humidity: 59.07%rH
Temp: 27.70DegC
Pressure: 907.9hpa
Resistance: 67998ohms

Humidity: 58.98%rH
Temp: 27.70DegC
Pressure: 907.9hpa
Resistance: 69906ohms

BME688 Readings

Humidity: 55.95%rH
Temp: 28.18DegC
Pressure: 907.1hpa
Resistance: 15100ohms

Humidity: 55.94%rH
Temp: 28.19DegC
Pressure: 907.1hpa
Resistance: 15500ohms

BME688 Gas resistance values are getting from 5600 slowly increasing after sometime it reached some level.

0andriy
  • 4,183
  • 1
  • 24
  • 37
LinuxGuys
  • 1
  • 2

0 Answers0