Skip to content

Commit

Permalink
Merge pull request #20 from klagr/corr-branch
Browse files Browse the repository at this point in the history
Corr branch
  • Loading branch information
finitespace authored Feb 7, 2017
2 parents 87ddea6 + f6db78e commit b6f7b30
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions examples/BME280_Modes/BME280_Modes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ BME280I2C bme; // Default : forced mode, standby time = 1000
// RMS Noise = 3.3 Pa/30 cm, 0.07 %RH
// Data Output Rate 1/60 Hz

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

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


//BME280I2C bme(3, 1, 0, 1, 0, 4); // Gaming : normal mode, standby time = 0.5ms
//BME280I2C bme(1, 0, 4, 3, 0, 4); // Gaming : normal mode, standby time = 0.5ms
// pressure ×4, temperature ×1, humidity ×0, filter = x16
// Current Consumption = 581 μA
// RMS Noise = 0.3 Pa/2.5 cm
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=BME280
version=2.1.02
version=2.1.2
author=Tyler Glenn <protglenn@gmail.com>
maintainer=Tyler Glenn <protglenn@gmail.com>
sentence=Provides a library for reading and interpreting Bosch BME280 environmental sensor data over I2C and SPI.
Expand Down
4 changes: 2 additions & 2 deletions src/BME280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ float BME280::CalculatePressure(int32_t raw, int32_t t_fine, uint8_t unit){
final /= 101324.99766353; /* final pa * 1 atm/101324.99766353Pa */
break;
case 0x4: /* bar */
final /= 100*1000; /* final pa * 1 bar/100kPa */
final /= 100000.0; /* final pa * 1 bar/100kPa */
break;
case 0x5: /* torr */
final /= 133.32236534674; /* final pa * 1 torr/133.32236534674Pa */
Expand Down Expand Up @@ -156,7 +156,7 @@ float BME280::temp(bool celsius){
return CalculateTemperature(rawTemp, t_fine, celsius);
}

float BME280::press(uint8_t unit){
float BME280::pres(uint8_t unit){
int32_t data[8];
int32_t t_fine;
if(!ReadData(data)){ return NAN; }
Expand Down
6 changes: 3 additions & 3 deletions src/BME280.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class BME280{

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

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

/* ==== Read the pressure from the BME280 and return a float with the specified unit. ==== */
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
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

/* ==== Read the humidity from the BME280 and return a percentage as a float. ==== */
float hum();
Expand Down
9 changes: 8 additions & 1 deletion src/BME280I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,26 @@ bool BME280I2C::ReadTrim()
dig[ord++] = Wire.read();
}

#ifdef DEBUG_ON
Serial.print("Dig: ");
for(int i = 0; i < 32; ++i)
{
Serial.print(dig[i], HEX);
Serial.print(" ");
}
Serial.println();

#endif

return ord == 32;
}

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

// for forced mode we need to write the mode to BME280 register before reading
if ( (mode == 0x01) || (mode == 0x10) )
setMode(mode);

// Registers are in order. So we can start at the pressure register and read 8 bytes.
Wire.beginTransmission(bme_280_addr);
Wire.write(PRESS_ADDR);
Expand All @@ -121,13 +126,15 @@ bool BME280I2C::ReadData(int32_t data[8]){
data[ord++] = Wire.read();
}

#ifdef DEBUG_ON
Serial.print("Data: ");
for(int i = 0; i < 8; ++i)
{
Serial.print(data[i], HEX);
Serial.print(" ");
}
Serial.println();
#endif

return ord == 8;
}
Expand Down
4 changes: 2 additions & 2 deletions src/BME280I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class BME280I2C: public BME280{

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

/* ==== Method used at start up to initialize the class. Starts the I2C interface. ==== */
virtual bool begin();
Expand Down
4 changes: 2 additions & 2 deletions src/BME280Spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class BME280Spi: public BME280{

public:
/* ==== Constructor used to create the class. All parameters have default values. ==== */
BME280Spi(uint8_t spiCsPin, uint8_t tosr = 0x1, 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.
BME280Spi(uint8_t spiCsPin, uint8_t tosr = 0x1, 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.

/* ==== Method used at start up to initialize the class. Starts the I2C interface. ==== */
virtual bool begin();
Expand Down
2 changes: 1 addition & 1 deletion src/BME280SpiSw.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BME280SpiSw: public BME280{
public:
/* ==== Constructor for software spi ==== */
BME280SpiSw(uint8_t spiCsPin, uint8_t spiMosiPin, uint8_t spiMisoPin, uint8_t spiSckPin, uint8_t tosr = 0x1,
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.
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.

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

0 comments on commit b6f7b30

Please sign in to comment.