Merge pull request #60 from jrussek/master

Put BME280 to sleep before changing configuration
This commit is contained in:
Limor "Ladyada" Fried 2019-08-25 13:48:28 -04:00 committed by GitHub
commit d144a3dbbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.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
// CONTROLHUMID register, otherwise the values won't be applied (see
// DS 5.4.3)