Skip to content

Commit b6f7b30

Browse files
authored
Merge pull request #20 from klagr/corr-branch
Corr branch
2 parents 87ddea6 + f6db78e commit b6f7b30

File tree

8 files changed

+22
-15
lines changed

8 files changed

+22
-15
lines changed

examples/BME280_Modes/BME280_Modes.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ BME280I2C bme; // Default : forced mode, standby time = 1000
4343
// RMS Noise = 3.3 Pa/30 cm, 0.07 %RH
4444
// Data Output Rate 1/60 Hz
4545

46-
//BME280I2C bme(0, 1, 1); // Humidity Sensing : forced mode, 1 sample/second
46+
//BME280I2C bme(1, 1, 0); // Humidity Sensing : forced mode, 1 sample/second
4747
// pressure ×0, temperature ×1, humidity ×1, filter off
4848
// Current Consumption = 2.9 μA
4949
// RMS Noise = 0.07 %RH
5050
// Data Output Rate = 1 Hz
5151

52-
//BME280I2C bme(5, 2, 1, 1, 0, 4); // Indoor Navigation : normal mode, standby time = 0.5ms
52+
//BME280I2C bme(2, 1, 5, 3, 0, 4); // Indoor Navigation : normal mode, standby time = 0.5ms
5353
// pressure ×16, temperature ×2, humidity ×1, filter = x16
5454
// Current Consumption = 633 μA
5555
// RMS Noise = 0.2 Pa/1.7 cm
@@ -58,7 +58,7 @@ BME280I2C bme; // Default : forced mode, standby time = 1000
5858
// Response Time (75%) = 0.9 s
5959

6060

61-
//BME280I2C bme(3, 1, 0, 1, 0, 4); // Gaming : normal mode, standby time = 0.5ms
61+
//BME280I2C bme(1, 0, 4, 3, 0, 4); // Gaming : normal mode, standby time = 0.5ms
6262
// pressure ×4, temperature ×1, humidity ×0, filter = x16
6363
// Current Consumption = 581 μA
6464
// RMS Noise = 0.3 Pa/2.5 cm

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=BME280
2-
version=2.1.02
2+
version=2.1.2
33
author=Tyler Glenn <[email protected]>
44
maintainer=Tyler Glenn <[email protected]>
55
sentence=Provides a library for reading and interpreting Bosch BME280 environmental sensor data over I2C and SPI.

src/BME280.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ float BME280::CalculatePressure(int32_t raw, int32_t t_fine, uint8_t unit){
113113
final /= 101324.99766353; /* final pa * 1 atm/101324.99766353Pa */
114114
break;
115115
case 0x4: /* bar */
116-
final /= 100*1000; /* final pa * 1 bar/100kPa */
116+
final /= 100000.0; /* final pa * 1 bar/100kPa */
117117
break;
118118
case 0x5: /* torr */
119119
final /= 133.32236534674; /* final pa * 1 torr/133.32236534674Pa */
@@ -156,7 +156,7 @@ float BME280::temp(bool celsius){
156156
return CalculateTemperature(rawTemp, t_fine, celsius);
157157
}
158158

159-
float BME280::press(uint8_t unit){
159+
float BME280::pres(uint8_t unit){
160160
int32_t data[8];
161161
int32_t t_fine;
162162
if(!ReadData(data)){ return NAN; }

src/BME280.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class BME280{
8282

8383
public:
8484
/* ==== Constructor used to create the class. All parameters have default values. ==== */
85-
BME280(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3,
86-
uint8_t st = 0x5, uint8_t filter = 0x0, bool spiEnable = false); // Oversampling = 1, mode = normal, standby time = 1000ms, filter = none.
85+
BME280(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x1,
86+
uint8_t st = 0x5, uint8_t filter = 0x0, bool spiEnable = false); // Oversampling = 1, mode = forced, standby time = 1000ms, filter = none.
8787

8888
/* ==== Method used at start up to initialize the class. ==== */
8989
virtual bool begin()=0;
@@ -94,7 +94,7 @@ class BME280{
9494
float temp(bool celsius = true);
9595

9696
/* ==== Read the pressure from the BME280 and return a float with the specified unit. ==== */
97-
float press(uint8_t unit = 0x0); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
97+
float pres(uint8_t unit = 0x0); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
9898

9999
/* ==== Read the humidity from the BME280 and return a percentage as a float. ==== */
100100
float hum();

src/BME280I2C.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,26 @@ bool BME280I2C::ReadTrim()
9696
dig[ord++] = Wire.read();
9797
}
9898

99+
#ifdef DEBUG_ON
99100
Serial.print("Dig: ");
100101
for(int i = 0; i < 32; ++i)
101102
{
102103
Serial.print(dig[i], HEX);
103104
Serial.print(" ");
104105
}
105106
Serial.println();
106-
107+
#endif
107108

108109
return ord == 32;
109110
}
110111

111112
bool BME280I2C::ReadData(int32_t data[8]){
112113
uint8_t ord = 0;
113114

115+
// for forced mode we need to write the mode to BME280 register before reading
116+
if ( (mode == 0x01) || (mode == 0x10) )
117+
setMode(mode);
118+
114119
// Registers are in order. So we can start at the pressure register and read 8 bytes.
115120
Wire.beginTransmission(bme_280_addr);
116121
Wire.write(PRESS_ADDR);
@@ -121,13 +126,15 @@ bool BME280I2C::ReadData(int32_t data[8]){
121126
data[ord++] = Wire.read();
122127
}
123128

129+
#ifdef DEBUG_ON
124130
Serial.print("Data: ");
125131
for(int i = 0; i < 8; ++i)
126132
{
127133
Serial.print(data[i], HEX);
128134
Serial.print(" ");
129135
}
130136
Serial.println();
137+
#endif
131138

132139
return ord == 8;
133140
}

src/BME280I2C.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class BME280I2C: public BME280{
5454

5555
public:
5656
/* ==== Constructor used to create the class. All parameters have default values. ==== */
57-
BME280I2C(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3,
57+
BME280I2C(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x1,
5858
uint8_t st = 0x5, uint8_t filter = 0x0, bool spiEnable = false,
59-
uint8_t bme_280_addr = 0x76); // Oversampling = 1, mode = normal, standby time = 1000ms, filter = none.
59+
uint8_t bme_280_addr = 0x76); // Oversampling = 1, mode = forced, standby time = 1000ms, filter = none.
6060

6161
/* ==== Method used at start up to initialize the class. Starts the I2C interface. ==== */
6262
virtual bool begin();

src/BME280Spi.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class BME280Spi: public BME280{
6060

6161
public:
6262
/* ==== Constructor used to create the class. All parameters have default values. ==== */
63-
BME280Spi(uint8_t spiCsPin, uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3,
64-
uint8_t st = 0x5, uint8_t filter = 0x0); // Oversampling = 1, mode = normal, standby time = 1000ms, filter = none.
63+
BME280Spi(uint8_t spiCsPin, uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x1,
64+
uint8_t st = 0x5, uint8_t filter = 0x0); // Oversampling = 1, mode = forced, standby time = 1000ms, filter = none.
6565

6666
/* ==== Method used at start up to initialize the class. Starts the I2C interface. ==== */
6767
virtual bool begin();

src/BME280SpiSw.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class BME280SpiSw: public BME280{
6767
public:
6868
/* ==== Constructor for software spi ==== */
6969
BME280SpiSw(uint8_t spiCsPin, uint8_t spiMosiPin, uint8_t spiMisoPin, uint8_t spiSckPin, uint8_t tosr = 0x1,
70-
uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0); // Oversampling = 1, mode = normal, standby time = 1000ms, filter = none.
70+
uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x1, uint8_t st = 0x5, uint8_t filter = 0x0); // Oversampling = 1, mode = forced, standby time = 1000ms, filter = none.
7171

7272
/* ==== Method used at start up to initialize the class. Starts the I2C interface. ==== */
7373
virtual bool begin();

0 commit comments

Comments
 (0)