Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Adafruit_BME280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -336,14 +334,14 @@ 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;
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));
Expand All @@ -360,16 +358,16 @@ 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;
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;
Expand Down Expand Up @@ -399,17 +397,16 @@ 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;
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);
Expand Down
4 changes: 2 additions & 2 deletions Adafruit_BME280.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ class Adafruit_BME280 {
/// 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); }
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit BME280 Library
version=2.2.4
version=2.3.0
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Arduino library for BME280 sensors.
Expand Down