From b13b3c9a6e815f82cdf659151139a3e5cf176679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Ru=C3=9Fek?= Date: Sun, 25 Aug 2019 09:52:11 -0400 Subject: [PATCH] Put BME280 to sleep before changing configuration As mentioned in https://github.com/adafruit/Adafruit_BME280_Library/issues/30 --- Adafruit_BME280.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Adafruit_BME280.cpp b/Adafruit_BME280.cpp index 7b89736..1e57b6f 100644 --- a/Adafruit_BME280.cpp +++ b/Adafruit_BME280.cpp @@ -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)