The calibration table for pressure and temperature is subtracted from the registers calib25...calib00 located at addresses 0x88 - 0xA1 Reading is carried out immediately 24 bytes(as described in the chapter "3.9 Data readout" Data sheet) Read data starting from address 0x88: unsigned short LSB bf MSB 00 dig_T1 00bf short LSB 00 MSB 00 dig_T2 0000 short LSB 00 MSB ff dig_T3 ff00 unsigned short LSB 81 MSB 03 dig_P1 0381 short LSB 0f MSB 00 dig_P2 000f short LSB 00 MSB 00 dig_P3 0000 short LSB 00 MSB ff dig_P4 ff00 short LSB 00 MSB 00 dig_P5 0000 short LSB 00 MSB 00 dig_P6 0000 short LSB 00 MSB 00 dig_P7 0000 short LSB ff MSB ff dig_P8 ffff short LSB 00 MSB ff dig_P9 ff00 To calculate the temperature and pressure data, the recommended "compensation" formulas were used using the obtained " raw " temperature and pressure data and calibration data: // Returns temperature in DegC, resolution is 0.01 DegC. Output value of “5123” equals 51.23 DegC. int bmp280_compensate_T_int32(int adc_T) { int var1, var2, T; var1 = ((((adc_T>>3) - ((int)dig_T1<<1))) * ((int)dig_T2)) >> 11; var2 = (((((adc_T>>4) - ((int)dig_T1)) * ((adc_T>>4) - ((int)dig_T1))) >> 12) *((int)dig_T3)) >> 14; t_fine = var1 + var2; T = (t_fine * 5 + 128) >> 8; return T; } // Returns pressure in Pa as unsigned 32 bit integer. Output value of “96386” equals 96386 Pa = 963.86 hPa uint32_t bmp280_compensate_P_int32(uint32_t adc_P) { int32_t var1, var2; uint32_t p; var1 = (((uint32_t)t_fine)>>1) - (uint32_t)64000; var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((uint32_t)dig_P6); var2 = var2 + ((var1*((uint32_t)dig_P5))<<1); var2 = (var2>>2)+(((uint32_t)dig_P4)<<16); var1 = (((dig_P3 * (((var1>>2) * (var1>>2)) >> 13 )) >> 3) + ((((uint32_t)dig_P2) * var1)>>1))>>18; var1 =((((32768+var1))*((uint32_t)dig_P1))>>15); if(var1 == 0) { return 0; // avoid exception caused by division by zero } p = (((uint32_t)(((uint32_t)1048576)-adc_P)-(var2>>12)))*3125; if(p < 0x80000000) { p = (p << 1) / ((uint32_t)var1); } else { p = (p / (uint32_t)var1) * 2; } var1 = (((uint32_t)dig_P9) * ((uint32_t)(((p>>3) * (p>>3))>>13)))>>12; var2 = (((uint32_t)(p>>2)) * ((uint32_t)dig_P8))>>13; p = (uint32_t)((uint32_t)p + ((var1 + var2 + dig_P7) >> 4)); return p; } Results of temperature and pressure measurements ----- in the room(really +26 - +28 )--------------------------------------
... View more