@@ -66,8 +66,19 @@ bool Adafruit_BME280::begin(uint8_t addr)
66
66
if (read8 (BME280_REGISTER_CHIPID) != 0x60 )
67
67
return false ;
68
68
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
+
69
80
readCoefficients (); // read trimming parameters, see DS 4.2.2
70
-
81
+
71
82
setSampling (); // use defaults
72
83
73
84
return true ;
@@ -303,7 +314,8 @@ void Adafruit_BME280::takeForcedMeasurement()
303
314
write8 (BME280_REGISTER_CONTROL, _measReg.get ());
304
315
// wait until measurement has been completed, otherwise we would read
305
316
// the values from the last measurement
306
- while (read8 (BME280_REGISTER_STATUS) & 0x08 );
317
+ while (read8 (BME280_REGISTER_STATUS) & 0x08 )
318
+ delay (1 );
307
319
}
308
320
}
309
321
@@ -337,6 +349,18 @@ void Adafruit_BME280::readCoefficients(void)
337
349
_bme280_calib.dig_H6 = (int8_t )read8 (BME280_REGISTER_DIG_H6);
338
350
}
339
351
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
+
340
364
341
365
/* *************************************************************************/
342
366
/* !
0 commit comments