On begin, read coefficients after calibration

This commit is contained in:
Frank Leon Rose 2017-02-09 10:21:13 -05:00
parent f741893e28
commit 50fb31ace1
2 changed files with 26 additions and 2 deletions

View File

@ -66,8 +66,19 @@ bool Adafruit_BME280::begin(uint8_t addr)
if (read8(BME280_REGISTER_CHIPID) != 0x60) if (read8(BME280_REGISTER_CHIPID) != 0x60)
return false; return false;
readCoefficients(); // read trimming parameters, see DS 4.2.2 // reset the device using soft-reset
// this makes sure the IIR is off, etc.
write8(BME280_REGISTER_SOFTRESET, 0xB6);
// wait for chip to wake up.
delay(300);
// if chip is still reading calibration, delay
while (isReadingCalibration())
delay(100);
readCoefficients();
setSampling(); // use defaults setSampling(); // use defaults
return true; return true;
@ -338,6 +349,18 @@ void Adafruit_BME280::readCoefficients(void)
_bme280_calib.dig_H6 = (int8_t)read8(BME280_REGISTER_DIG_H6); _bme280_calib.dig_H6 = (int8_t)read8(BME280_REGISTER_DIG_H6);
} }
/**************************************************************************/
/*!
@brief return true if chip is busy reading cal data
*/
/**************************************************************************/
bool Adafruit_BME280::isReadingCalibration(void)
{
uint8_t const rStatus = read8(BME280_REGISTER_STATUS);
return (rStatus & (1 << 0)) != 0;
}
/**************************************************************************/ /**************************************************************************/
/*! /*!

View File

@ -187,6 +187,7 @@ class Adafruit_BME280 {
private: private:
void readCoefficients(void); void readCoefficients(void);
bool isReadingCalibration(void);
uint8_t spixfer(uint8_t x); uint8_t spixfer(uint8_t x);
void write8(byte reg, byte value); void write8(byte reg, byte value);