Skip to content

Commit 09536be

Browse files
committed
Merge branch 'master' of github.com:adafruit/Adafruit_BME280_Library
2 parents a148538 + f1e1490 commit 09536be

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Adafruit_BME280.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,19 @@ bool Adafruit_BME280::begin(uint8_t addr)
6666
if (read8(BME280_REGISTER_CHIPID) != 0x60)
6767
return false;
6868

69+
// reset the device using soft-reset
70+
// this makes sure the IIR is off, etc.
71+
write8(BME280_REGISTER_SOFTRESET, 0xB6);
72+
73+
// wait for chip to wake up.
74+
delay(300);
75+
76+
// if chip is still reading calibration, delay
77+
while (isReadingCalibration())
78+
delay(100);
79+
6980
readCoefficients(); // read trimming parameters, see DS 4.2.2
70-
81+
7182
setSampling(); // use defaults
7283

7384
return true;
@@ -303,7 +314,8 @@ void Adafruit_BME280::takeForcedMeasurement()
303314
write8(BME280_REGISTER_CONTROL, _measReg.get());
304315
// wait until measurement has been completed, otherwise we would read
305316
// the values from the last measurement
306-
while (read8(BME280_REGISTER_STATUS) & 0x08);
317+
while (read8(BME280_REGISTER_STATUS) & 0x08)
318+
delay(1);
307319
}
308320
}
309321

@@ -337,6 +349,18 @@ void Adafruit_BME280::readCoefficients(void)
337349
_bme280_calib.dig_H6 = (int8_t)read8(BME280_REGISTER_DIG_H6);
338350
}
339351

352+
/**************************************************************************/
353+
/*!
354+
@brief return true if chip is busy reading cal data
355+
*/
356+
/**************************************************************************/
357+
bool Adafruit_BME280::isReadingCalibration(void)
358+
{
359+
uint8_t const rStatus = read8(BME280_REGISTER_STATUS);
360+
361+
return (rStatus & (1 << 0)) != 0;
362+
}
363+
340364

341365
/**************************************************************************/
342366
/*!

Adafruit_BME280.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class Adafruit_BME280 {
187187

188188
private:
189189
void readCoefficients(void);
190+
bool isReadingCalibration(void);
190191
uint8_t spixfer(uint8_t x);
191192

192193
void write8(byte reg, byte value);

0 commit comments

Comments
 (0)