Put BME280 to sleep before changing configuration

As mentioned in https://github.com/adafruit/Adafruit_BME280_Library/issues/30
This commit is contained in:
Johannes Rußek 2019-08-25 09:52:11 -04:00
parent 9d2136d663
commit b13b3c9a6e
1 changed files with 5 additions and 0 deletions

View File

@ -185,6 +185,11 @@ void Adafruit_BME280::setSampling(sensor_mode mode,
_configReg.filter = filter; _configReg.filter = filter;
_configReg.t_sb = duration; _configReg.t_sb = duration;
// making sure sensor is in sleep mode before setting configuration
// as it otherwise may be ignored
write8(BME280_REGISTER_CONTROL, MODE_SLEEP);
// you must make sure to also set REGISTER_CONTROL after setting the // you must make sure to also set REGISTER_CONTROL after setting the
// CONTROLHUMID register, otherwise the values won't be applied (see // CONTROLHUMID register, otherwise the values won't be applied (see
// DS 5.4.3) // DS 5.4.3)