P8 doubts #53
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Indeed, it is just as you say. The registers In this case, the manufacturer, instead of giving us a general formula, gives us some specific parameters for each chip: You have to read the sensor registers and the calibration registers and, with them, use the formulas indicated in the datasheet to obtain the final result. For example, if you get the temperature registers ( uint8_t temp_msb; // Register 0xFA
uint8_t temp_lsb; // Register 0xFB
uint8_t temp_xlsb; // Register 0xFC
int32_t adc_T; // Union of temp_msb, temp_lsb, and temp_xlsb
uint16_t dig_T1; // Union of registers 0x88...0x89
int16_t dig_T2; // Union of registers 0x8A...0x8B
int16_t dig_T3; // Union of registers 0x8C...0x8D
// Here you get the value of the registers using I2C/SPI and save them in the corresponding variable.
// Also, merge the read array of bytes temp_msb, temp_lsb, and temps_xlsb in a single 32-bits
// variables called adc_T (unions?)
double temp;
double var1;
double var2;
var1 = (((double)adc_T)/16384.0 - ((double)dig_T1)/1024.0) * ((double)dig_T2);
var2 = ((((double)adc_T)/131072.0 - ((double)dig_T1)/8192.0) *
(((double)adc_T)/131072.0 - ((double)dig_T1)/8192.0)) * ((double)dig_T3);
temp = (var1 + var2) / 5120.0;
|
Beta Was this translation helpful? Give feedback.
-
|
Hi! I just tried this and I don't quite understand when dig_T# come into play. |
Beta Was this translation helpful? Give feedback.
-
|
For example, to read uint16_t dig_T1;
Wire.beginTransmission(0x77);
Wire.write(0x88);
Wire.endTransmission();
Wire.requestFrom(0x77, 2);
while(Wire.available() < 2) {};
dig_T1 = (uint16_t)Wire.read();
dig_T1 = dig_T1 | (((uint16_t)Wire.read()) << 8); |
Beta Was this translation helpful? Give feedback.



Indeed, it is just as you say. The registers
0xFA...0xFC,0xFD...0xFEand0xF7...0xF9contain the results of temperature, humidity and pressure, respectively. These are read-only registers (they cannot be written to) and these results are directly the value given by the internal ADC of the BME280. You already know from previous practices, that ADCs return a digital integer value and must be converted to the final result using formulas.In this case, the manufacturer, instead of giving us a general formula, gives us some specific parameters for each chip:
dig_T1,dig_T2,..., etc., which are the ones you have attached in the issue. Each sensor that is manufactured, no matter how good the ma…