03-30-2023 04:54 AM
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, ...
03-30-2023 04:56 PM
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
03-30-2023 11:03 PM
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?
05-05-2023 08:17 AM
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?