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?
... View more