Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Getting error in bme680 calibration function.

    Getting error in bme680 calibration function.

    Established Member


    I am trying to get compile bme680_init() function only and it interfaced with the BlueNRG-2 (BLE+MCU)module. I am using  Keil compiller. Please look below for reference

    struct bme680_dev gas_sensor;

    /* You may assign a chip select identifier to be handled later */
    gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY;
    gas_sensor.intf = BME680_I2C_INTF; = i2c_read;
    gas_sensor.write = i2c_write;
    gas_sensor.delay_ms = delay_ms;
    /* amb_temp can be set to 25 prior to configuring the gas sensor
    * or by performing a few temperature readings without operating the gas sensor.
    gas_sensor.amb_temp = 25;

    int8_t rslt = BME680_OK;
    rslt = bme680_init(&gas_sensor);
    printf("BME680 InIt Result: ");


    But I am getting issue at  rslt = bme680_get_regs(BME680_COEFF_ADDR1, coeff_array, BME680_COEFF_ADDR1_LEN, dev);

    in get_calib_data () function. Here Program is stuck and getting  error in I2C reading. But I am getting proper Chip ID 0x61 while reading  chip ID . So I am assuming my I2C lines are working. Also tested with other sensor and confirm I2C line is working.  I have also checked about BME680_COEFF_ADDR1 and that is 0x89 given in bme680_def.h file. But It is not mentioned anywhere in datasheet. 

    Can you please Guide me where I am doing wrong. Please Guide. 

    31 REPLIES 31

    Community Moderator
    Community Moderator

    Hi Sudeep1310,

    The temperature within the package is expected to increase with operation due to the heat dissipated by the gas sensor.  The bias stabiliizes depending on the operating mode and ambient temperature. This sensor heat can be compensated for with the use of the BSEC algorithm. 

    It is however strange that the gas measurement readings are so low. My intial guess is that the sensor might be contaminated and hence suggest reading the  HSMI manual. 

    Regarding the Status flags, it is a logic OR combination of the 3 flags,

    #define BME680_NEW_DATA_MSK    UINT8_C(0x80)
    #define BME680_GASM_VALID_MSK  UINT8_C(0x20)
    #define BME680_HEAT_STAB_MSK   UINT8_C(0x10)

    and hence 0xb0 means that there was a valid gas measurement and the data is new (not a repeat), and the heater was stable. 0xa0 means that the heater was unstable for that measurement, basically signifying that there wasn't sufficient time to heat the gas sensor to the needed temperature. This is pretty common for a cold start and normally observed after a power on reset for the first measurement. 

    Established Member

    Hello  Kgoveas,

    You are right gas measurement value is so low as I compared with reading taken by same sensor interfaced with arduino board. 


    Temperature in Celsius: 30.04
    Humidity in %: 31.27
    Pressure in hPa: 944.86
    Altitude in Meters: 583.53
    Gas Resistance in Ohms: 16603.89

    I was not seen properly thatswhy I have mentioned wrong  statement. But yes value of Gas resistance getting  with API  as below may be wrong.

    Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%), Gas resistance(ohm), Status
    1, 1000, 28.75, 94488.88, 35.88, 5825.59, 0xa0
    2, 1000, 28.98, 94491.52, 35.91, 1831.92, 0xb0
    3, 1000, 29.48, 94483.83, 35.98, 1680.24, 0xb0
    4, 1000, 29.97, 94487.53, 36.05, 1686.79, 0xb0
    5, 1000, 30.32, 94488.09, 36.12, 1692.28, 0xb0
    6, 1000, 30.56, 94490.24, 36.14, 1724.87, 0xb0
    7, 1000, 30.76, 94494.60, 36.15, 1746.91, 0xb0
    8, 1000, 30.94, 94484.99, 36.14, 1765.91, 0xb0
    9, 1000, 31.09, 94492.68, 36.11, 1779.22, 0xb0
    10, 1000, 31.22, 94493.74, 36.07, 1806.44, 0xb0

    I will check once again for all possible cases and let you know. Your suggestion also important to me. So if I need to change anything please suggest. I will give you feedback after testing once again.