From c93725cc17cd18666ad9c66309b1780c5235d261 Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 30 Apr 2025 13:10:55 +0100 Subject: [PATCH 1/6] Cleanup incorrect comment from https://github.com/adafruit/Adafruit_BME280_Library/commit/553c635a811297c6d4079f0d5c6ef8e6f0b1abe2 --- Adafruit_BME280.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Adafruit_BME280.cpp b/Adafruit_BME280.cpp index 4c82e05..d4039a4 100644 --- a/Adafruit_BME280.cpp +++ b/Adafruit_BME280.cpp @@ -132,8 +132,6 @@ bool Adafruit_BME280::init() { /*! * @brief setup sensor with given parameters / settings * - * This is simply a overload to the normal begin()-function, so SPI users - * don't get confused about the library requiring an address. * @param mode the power mode to use for the sensor * @param tempSampling the temp samping rate to use * @param pressSampling the pressure sampling rate to use From 5b119e24f6f2f3410c65d14929f80381eac56fac Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 30 Apr 2025 13:18:44 +0100 Subject: [PATCH 2/6] Update humidity sampling register comment --- Adafruit_BME280.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adafruit_BME280.h b/Adafruit_BME280.h index ffa8018..abeef85 100644 --- a/Adafruit_BME280.h +++ b/Adafruit_BME280.h @@ -354,14 +354,14 @@ protected: /// unused - don't set unsigned int none : 5; - // pressure oversampling + // humidity oversampling // 000 = skipped // 001 = x1 // 010 = x2 // 011 = x4 // 100 = x8 // 101 and above = x16 - unsigned int osrs_h : 3; ///< pressure oversampling + unsigned int osrs_h : 3; ///< humidity oversampling /// @return combined ctrl hum register unsigned int get() { return (osrs_h); } From 88903ef84ea488e89b4af27643eaa27ce0e30cca Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 30 Apr 2025 13:44:05 +0100 Subject: [PATCH 3/6] Check register values for no sampling --- Adafruit_BME280.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Adafruit_BME280.cpp b/Adafruit_BME280.cpp index d4039a4..4e822fe 100644 --- a/Adafruit_BME280.cpp +++ b/Adafruit_BME280.cpp @@ -338,10 +338,10 @@ bool Adafruit_BME280::isReadingCalibration(void) { */ float Adafruit_BME280::readTemperature(void) { int32_t var1, var2; + if (_measReg.osrs_t == sensor_sampling::SAMPLING_NONE) + return NAN; int32_t adc_T = read24(BME280_REGISTER_TEMPDATA); - if (adc_T == 0x800000) // value in case temp measurement was disabled - return NAN; adc_T >>= 4; var1 = (int32_t)((adc_T / 8) - ((int32_t)_bme280_calib.dig_T1 * 2)); @@ -362,12 +362,12 @@ float Adafruit_BME280::readTemperature(void) { */ float Adafruit_BME280::readPressure(void) { int64_t var1, var2, var3, var4; + if (_measReg.osrs_p == sensor_sampling::SAMPLING_NONE) + return NAN; readTemperature(); // must be done first to get t_fine int32_t adc_P = read24(BME280_REGISTER_PRESSUREDATA); - if (adc_P == 0x800000) // value in case pressure measurement was disabled - return NAN; adc_P >>= 4; var1 = ((int64_t)t_fine) - 128000; @@ -401,13 +401,12 @@ float Adafruit_BME280::readPressure(void) { */ float Adafruit_BME280::readHumidity(void) { int32_t var1, var2, var3, var4, var5; + if (_humReg.osrs_h == sensor_sampling::SAMPLING_NONE) + return NAN; readTemperature(); // must be done first to get t_fine int32_t adc_H = read16(BME280_REGISTER_HUMIDDATA); - if (adc_H == 0x8000) // value in case humidity measurement was disabled - return NAN; - var1 = t_fine - ((int32_t)76800); var2 = (int32_t)(adc_H * 16384); var3 = (int32_t)(((int32_t)_bme280_calib.dig_H4) * 1048576); From 9d7abf01c7da4e489565912cb33c1f19209e02ee Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 30 Apr 2025 13:56:14 +0100 Subject: [PATCH 4/6] Bump version to 2.3.0 to signify NaN change --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 7a73557..c632c89 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit BME280 Library -version=2.2.4 +version=2.3.0 author=Adafruit maintainer=Adafruit sentence=Arduino library for BME280 sensors. From 4f69faddc5ebe2b82b96e0246bcd1b24502fa37c Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 30 Apr 2025 14:13:09 +0100 Subject: [PATCH 5/6] Add NaN to docstrings --- Adafruit_BME280.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adafruit_BME280.cpp b/Adafruit_BME280.cpp index 4e822fe..4439620 100644 --- a/Adafruit_BME280.cpp +++ b/Adafruit_BME280.cpp @@ -334,7 +334,7 @@ bool Adafruit_BME280::isReadingCalibration(void) { /*! * @brief Returns the temperature from the sensor - * @returns the temperature read from the device + * @returns the temperature read from the device or NaN if sampling off */ float Adafruit_BME280::readTemperature(void) { int32_t var1, var2; @@ -358,7 +358,7 @@ float Adafruit_BME280::readTemperature(void) { /*! * @brief Returns the pressure from the sensor - * @returns the pressure value (in Pascal) read from the device + * @returns the pressure value (in Pascal) or NaN if sampling off */ float Adafruit_BME280::readPressure(void) { int64_t var1, var2, var3, var4; @@ -397,7 +397,7 @@ float Adafruit_BME280::readPressure(void) { /*! * @brief Returns the humidity from the sensor - * @returns the humidity value read from the device + * @returns the humidity value read from the device or NaN if sampling off */ float Adafruit_BME280::readHumidity(void) { int32_t var1, var2, var3, var4, var5; From ba0fe3d3c04f723889ecce0000326da6c059837e Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 30 Apr 2025 14:29:35 +0100 Subject: [PATCH 6/6] Fix product links in examples. Closes #102 --- examples/advancedsettings/advancedsettings.ino | 2 +- examples/bme280test/bme280test.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/advancedsettings/advancedsettings.ino b/examples/advancedsettings/advancedsettings.ino index df1f5eb..4cce2b5 100644 --- a/examples/advancedsettings/advancedsettings.ino +++ b/examples/advancedsettings/advancedsettings.ino @@ -2,7 +2,7 @@ This is a library for the BME280 humidity, temperature & pressure sensor Designed specifically to work with the Adafruit BME280 Breakout - ----> http://www.adafruit.com/products/2650 + ----> http://www.adafruit.com/products/2652 These sensors use I2C or SPI to communicate, 2 or 4 pins are required to interface. The device's I2C address is either 0x76 or 0x77. diff --git a/examples/bme280test/bme280test.ino b/examples/bme280test/bme280test.ino index d28ce05..7f728c4 100644 --- a/examples/bme280test/bme280test.ino +++ b/examples/bme280test/bme280test.ino @@ -2,7 +2,7 @@ This is a library for the BME280 humidity, temperature & pressure sensor Designed specifically to work with the Adafruit BME280 Breakout - ----> http://www.adafruit.com/products/2650 + ----> http://www.adafruit.com/products/2652 These sensors use I2C or SPI to communicate, 2 or 4 pins are required to interface. The device's I2C address is either 0x76 or 0x77.