Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME680: Temperature values not updating

    BME680: Temperature values not updating

    gke2kor
    New Poster

    I have configured BME680 over I2C and I'm getting Pressure, Humidity, and Gas resistance values being updated for every read except the temperature values. temperature value is always at "0". 
    What would be the reason? Is this something to do with the configuration? 

    I have followed the exact procedure mentioned in the readme section.
    boschsensortec/BME680_driver: BME680 sensor driver / API including example guide. To report issues, ...

    3 REPLIES 3

    BSTRobin
    Community Moderator
    Community Moderator

    Hi gke2kor,

    Did you strictly refer example code in readme file?

    In addition, the latest BME68X sensor API and example is here https://github.com/boschsensortec/BME68x-Sensor-API

    Hi @BSTRobin,
    Yes, I followed the exact example code of the readme file.

    Before getting onto the latest Github link. I found out that calibration parameters of temperature-related coefficients par_t1 and par_t3 are updating correctly where as par_t2 is always "0". I'm not sure why this is "0" always. This should be updated during the "init" right? Do you see any problem here?

    BSTRobin
    Community Moderator
    Community Moderator

    Hi gke2kor,

    Temperature related coefficients t1, t2, t3 were read in bme68x_init() function.

    /* This internal API is used to read the calibration coefficients */
    static int8_t get_calib_data(struct bme68x_dev *dev)
    {
    ...
    /* Temperature related coefficients */
    dev->calib.par_t1 =
    (uint16_t)(BME68X_CONCAT_BYTES(coeff_array[BME68X_IDX_T1_MSB], coeff_array[BME68X_IDX_T1_LSB]));
    dev->calib.par_t2 =
    (int16_t)(BME68X_CONCAT_BYTES(coeff_array[BME68X_IDX_T2_MSB], coeff_array[BME68X_IDX_T2_LSB]));
    dev->calib.par_t3 = (int8_t)(coeff_array[BME68X_IDX_T3]);
    ...
    }

    /* @brief This API reads the chip-id of the sensor which is the first step to
    * verify the sensor and also calibrates the sensor
    * As this API is the entry point, call this API before using other APIs.
    */
    int8_t bme68x_init(struct bme68x_dev *dev)
    {
    int8_t rslt;

    rslt = bme68x_soft_reset(dev);
    if (rslt == BME68X_OK)
    {
    rslt = bme68x_get_regs(BME68X_REG_CHIP_ID, &dev->chip_id, 1, dev);
    if (rslt == BME68X_OK)
    {
    if (dev->chip_id == BME68X_CHIP_ID)
    {
    /* Read Variant ID */
    rslt = read_variant_id(dev);

    if (rslt == BME68X_OK)
    {
    /* Get the Calibration data */
    rslt = get_calib_data(dev);
    }
    }
    else
    {
    rslt = BME68X_E_DEV_NOT_FOUND;
    }
    }
    }

    return rslt;
    }

    When reading sensor data by calling bme68x_get_data() function, t1, t2, t3 will be used to calculate the temperature value.

    /* @brief This internal API is used to calculate the temperature value. */
    static int16_t calc_temperature(uint32_t temp_adc, struct bme68x_dev *dev)
    {
    int64_t var1;
    int64_t var2;
    int64_t var3;
    int16_t calc_temp;

    /*lint -save -e701 -e702 -e704 */
    var1 = ((int32_t)temp_adc >> 3) - ((int32_t)dev->calib.par_t1 << 1);
    var2 = (var1 * (int32_t)dev->calib.par_t2) >> 11;
    var3 = ((var1 >> 1) * (var1 >> 1)) >> 12;
    var3 = ((var3) * ((int32_t)dev->calib.par_t3 << 4)) >> 14;
    dev->calib.t_fine = (int32_t)(var2 + var3);
    calc_temp = (int16_t)(((dev->calib.t_fine * 5) + 128) >> 8);

    /*lint -restore */
    return calc_temp;
    }

    Did you strictly refer exameple code?

    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