Coder Social home page Coder Social logo

bme280's Introduction

BME280

Provides an Arduino library for reading and interpreting Bosch BME280 data over I2C, SPI or Sw SPI. Additional environment calculation functions are provided. ESP and BRZO are now supported.

Table of Contents

  1. BME280

  2. Table of Contents

  3. Summary

  4. Installation

  5. Usage

  6. Enumerations

  7. Settings

  8. Methods

  9. Environment Calculations

  10. Contributing

  11. History

  12. Credits

  13. License

Summary

Reads temperature, humidity, and pressure. Calculates altitude, equivalent sea level pressure and dew point. Provides functions for english and metric. Also reads pressure in Pa, hPa, inHg, atm, bar, torr, N/m^2 and psi.

Installation

To use this library download the zip file, decompress it to a folder named BME280. Move the folder to {Arduino Path}/libraries.

Usage

Include the library at the top of your Arduino script. #include <BME280> Create a global or local variable. BME280 bme In your start up call bme.begin(). Read the temperature, humidity, pressure, altitude and/or dew point.

float pres, temp, hum bme.read(pres, temp, hum)

or

temp = bme.temp() hum = bme.hum() pres = bme.pres()

Enumerations

TempUnit Enum

  • TempUnit_Celsius
  • TempUnit_Fahrenheit

PresUnit Enum

  • PresUnit_Pa
  • PresUnit_hPa
  • PresUnit_inHg
  • PresUnit_atm
  • PresUnit_bar
  • PresUnit_torr
  • PresUnit_psi

OSR Enum

  • OSR_Off
  • OSR_X1
  • OSR_X2
  • OSR_X4
  • OSR_X8
  • OSR_X16

Mode Enum

  • Mode_Sleep
  • Mode_Forced
  • Mode_Normal

StandbyTime Enum

  • StandbyTime_500us
  • StandbyTime_62500us
  • StandbyTime_125ms
  • StandbyTime_250ms
  • StandbyTime_50ms
  • StandbyTime_1000ms
  • StandbyTime_10ms
  • StandbyTime_20ms

Filter Enum

  • Filter_Off
  • Filter_1
  • Filter_2
  • Filter_4
  • Filter_8
  • Filter_16

ChipModel Enum

  • ChipModel_Unknown
  • ChipModel_BME280
  • ChipModel_BMP280

Settings

BME280::Settings Struct

    * Temperature Oversampling Rate (tempOSR): OSR Enum, default = OSR_X1

    * Humidity Oversampling Rate (humOSR): OSR Enum, default = OSR_X1

    * Pressure Oversampling Rate (presOSR): OSR Enum, default = OSR_X1

    * Mode (mode): Mode Enum, default = Mode_Forced

    * Standby Time (standbyTime): StandbyTime Enum, default = StandbyTime_1000ms

    * Filter (filter): Filter Enum, default = Filter_16

    * SPI Enable: SpiEnable Enum, default = false
      values: true = enable, false = disable

BME280I2C::Settings Struct

  • Includes all fields in BME280 settings.
   * BME 280 Address (bme280Addr): uint8_t, default = 0x76

BME280Spi::Settings Struct

  • Includes all fields in BME280 settings.
   * SPI Chip Select Pin (spiCsPin): uint8_t
      values: Any pin 0-31

BME280Spi::Settings Struct

  • Includes all fields in BME280 settings.
   * SPI Chip Select Pin (spiCsPin): uint8_t
     values: Any pin 0-31

   * SPI Master Out Slave In Pin (spiMosiPin): uint8_t
     values: Any pin 0-31

   * SPI Master In Slave Out Pin (spiMisoPin): uint8_t
     values: Any pin 0-31

   * SPI Serial Clock Pin (spiSckPin): uint8_t
     values: Any pin 0-31

Methods

BME280I2C(const BME280I2C::Settings& settings)

Constructor used to create the I2C Bme class. All parameters have default values.

BME280Spi(const BME280Spi::Settings& settings)

Constructor used to create the Spi Bme class. All parameters have default values except chip select.

BME280SpiSw(const BME280SpiSw::Settings& settings)

Constructor used to create the software Spi Bme class. All parameters have default values except chip select, mosi, miso and sck.

bool begin()

Method used at start up to initialize the class. Starts the I2C or SPI interface. Can be called again to re-initialize the mode settings.

Note: To allow the user to provide their own wire implementation, Wire.begin() (or the equalivant) must be called before bme.begin()

  * return: bool, true = success, false = failure (no device found)

void setSettings(const Settings& settings)

Method to set the sensor settings.

const Settings& getSettings() const

Method to get the sensor settings.

float temp(TempUnit unit)

Read the temperature from the BME280 and return a float.

    return: float = temperature

    * unit: tempUnit, default = TempUnit_Celsius

float pres(PresUnit unit)

Read the pressure from the BME280 and return a float with the specified unit.

    return: float = pressure

    * presUnit: uint8_t, default = PresUnit_hPa

float hum()

Read the humidity from the BME280 and return a percentage as a float.

    * return: float = percent relative humidity

void read(float& pressure, float& temp, float& humidity, TempUnit tempUnit, PresUnit presUnit)

Read the data from the BME280 with the specified units.

    return: None, however, pressure, temp and humidity are changed.

    * Pressure: float, reference
      values: reference to storage float for pressure

    * Temperature: float, reference
      values: reference to storage float for temperature

    * Humidity: float, reference
      values: reference to storage float for humidity

    * tempUnit: tempUnit, default = TempUnit_Celsius

    * presUnit: uint8_t, default = PresUnit_hPa

ChipModel chipModel()

    * return: [ChipModel](#chipmodel-enum) enum

Environment Calculations

float Altitude(float pressure, AltitudeUnit = AltitudeUnit_Meters, float seaLevelPressure = 1013.25, outsideTemp = 15.0, TempUnit = TempUnit_Celsius)

Calculate the altitude based on the pressure with the specified units.

    Return: float altitude

    * Pressure: float
      values: unit independent

    * AltitudeUnit: default = AltitudeUnit_Meters
      values:  AltitudeUnit_Meters, AltitudeUnit_Feet

    * Sea Level Pressure: float, default = 1013.25
      values:  unit independent

    * outsideTemp: float, default = 15.0
      values:  any float related to TempUnit

    * TempUnit: default = TempUnit_Celsius
      values: TempUnit_Celsius, TempUnit_Fahrenheit

      Note: The formula evaluates the height difference based on difference of pressure.
     - May be used to evaluate altitude over MSL. (default set)
                (default referencePressure, default outsideTemp parameters ~ ISA standard)
                The altitude is derived from QNH, used in aviation.
     - May be used to evaluate height over MSL
                (referencePressure should be equal to QFF read in meteorologic synoptic maps,
                outsideTemp should be equal to local temperature)
     - May be used to evaluate the height difference between two points
                (referencePressure should be set to the pressure on the lower point.)

float EquivalentSeaLevelPressure(float altitude, float temp, float pres, AltitudeUnit altUnit, TempUnit tempUnit )

Convert current pressure to equivalent sea-level pressure.

    Return: float equivalent pressure at sea level.

    * altitude: float
      values: meters

    * temp: float
      values: celsius

    * pres: float
      values: unit independent

    * AltitudeUnit: default = AltitudeUnit_Meters
      values:  AltitudeUnit_Meters, AltitudeUnit_Feet

    * TempUnit: default = TempUnit_Celsius
      values: TempUnit_Celsius, TempUnit_Fahrenheit

      Note: To get correct EquivalentSeaLevel pressure (QNH or QFF) the altitude value should be independent
      on measured pressure. It is necessary to use fixed altitude point e.g. the altitude of barometer
      read in map.

float DewPoint(float temp, float hum, TempUnit = TempUnit_Celsius)

Calculate the dew point based on the temperature and humidity with the specified units.

    return: float dew point

    * Temperature: float
      values: any float related to TempUnit

    * Humidity: float, unit = % relative humidity
      values: any float

    * TempUnit: TempUnit, default = TempUnit_Celsius
      values: TempUnit_Celsius = return degrees Celsius, TempUnit_Fahrenheit = return degrees Fahrenheit

float AbsoluteHumidity(float temperature, float humidity, TempUnit = TempUnit_Celsius)

Calculate the absolute humidity based on the temperature and humidity with the specified units.

    return: float absolute humidity

    * Temperature: float
      values: any float related to TempUnit

    * Humidity: float, unit = % relative humidity
      values: any float

    * TempUnit: TempUnit, default = TempUnit_Celsius
      values: TempUnit_Celsius = return degrees Celsius, TempUnit_Fahrenheit = return degrees Fahrenheit

float HeatIndex(float temperature, float humidity, TempUnit tempUnit = TempUnit_Celsius)

Calculate the heat index based on the temperature and humidity with the specified units. The U.S. NWS algorithm is used.

    return: float heat index in TempUnit

    * Temperature: float
      values: any float related to TempUnit

    * Humidity: float, unit = % relative humidity
      values: any float

    * TempUnit: TempUnit, default = TempUnit_Celsius
      values: TempUnit_Celsius = return degrees Celsius, TempUnit_Fahrenheit = return degrees Fahrenheit

Contributing

  1. Fork the project.
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

History

  • Jan 1, 2016 - Version 1.0.0 released
  • Sep 19, 2016 - Version 2.0.0 released (Restructure for I2C and SPI)
  • Nov 21, 2016 - Version 2.0.1 released (Set mode support)
  • Dec 19, 2016 - Version 2.1.0 released (Support for SPI)
  • Dec 21, 2016 - Version 2.1.1 released (Bugs)
  • Feb 17, 2017 - Version 2.1.2 released (Docs)
  • Sept 9, 2017 - Version 2.1.3 released (Formatting, reorg)
  • Sept 13, 2017 - Version 2.1.4 released (Examples update, bug fixes)
  • Oct 7, 2017 - Version 2.2.0 released (Enums, begin restructure)
  • Oct 10, 2017 - Version 2.2.1 released (Bug fixes)
  • Nov 21, 2017 - Version 2.3.0 released (Examples updates, env calc fixes, bugs)
  • Brief intermission
  • Dec xx, 2018. - Version 3.0.0 pending (A lot)

Credits

Written by Tyler Glenn, 2016.

Special thanks to Mike Glenn for editing and reviewing the code.

License

GNU GPL, see License.txt

bme280's People

Contributors

alexshavlovsky avatar amedeebulle avatar amunak avatar chacal avatar coelner avatar eykamp avatar finitespace avatar guruathwal avatar happywheels avatar jamesmyatt avatar jirkaptr avatar johanso-au avatar klagr avatar maru-sama avatar osos avatar per1234 avatar rpaskowitz avatar vortigont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bme280's Issues

Settings inheritance is ignored

When BME280 constructor is called settings is copied to a BME280::Settings member variable and child settings information is discarded. Subsequently, a call to getSettings() returns a const reference to member BME280::Settings. This forces child classes to hold member variables of settings instead of using getSettings()

Solutions:

  • Pointers.
  • Functions in every child class to set/get member variables.

**long** use instead of **float** use = possible?

I have a question:
After reading the BME280 datasheet I resume this:

    Min     MAX     unité   précision   résolution
    -40     +85     °C      +/-0.5      0.01
    0       100     %Hr     +/-3%       0.008
    30000   110000  Pa      +/-100      0.18

So the pressure can move between this scale:

    Pression atmospherique
        30000.00    110000.00    => *100
        3000000     11000000=>  3x Bytes (ou 1 long)    => /100.0
        => xxxxxx.xx Pa

But this is a 8 significant digit.
A float variable can only goes for 7 significant digit. Would be better to use a long variable?

Whatever I read that it is preferable to use long variables instead of float ones (less use of processor cycles if no dedicated FTU)
And I am transferring it on NRF24L01 so in every cases I have to cut into Bytes.

So, Is there a way to get long instead of float when reading?

Rename Celcius

In version 2.2.1 the temperature unit is named "Celcius". In fact, it does not cause a malfunction, but aesthetically ... old Celsius would be better.

ESP8266 crash

Hi!
Thanks for this awesome library!

I have a problem,
When I upload the example with Wire.pins (0,2) and then Wire.begin, It work great.
But when I upload my own code (send the data from BME280 to thingspeak) it crash immediately.
When I comment out bme.begin() it work and connect to the WiFi.
So it seems that bme.begin() cause the problem here.
Any ideas?

Thanks!

Read entire trim register.

Using one SPI register read the trim can be read all at once eliminating three register reads. The raw register array can be packed into the existing DIG member variable.

Defines are not honored in ino files

Arduino compiles all of the code in the src file** compiling our brzo and spi code. Arduino compiles files separately and #defines do not transfer across files. Therefore, a #ifdef cannot be used to surround the BME BRZO code. The result, all of the example builds fail if the BRZO code is not surrounded in a pre-processor macro. Likewise, this has caused issues in past I2C builds where #define <SPI.h> was required to build.

Current implementation requires user intervention in library files by modifying BME280I2C_BRZO.cpp::line 35: #define USING_BRZO 1.

**(TODO: check if src folder structure mitigates)

Compilation fails with current HEAD

Hello,

First of all, thank you very much for this nice library, it makes working with this sensor a breeze.
I am trying to use current HEAD with platformio and I am facing compilation issues. First of all you are including header file which does not exist in both BME280Spi.cpp and
BME280SPiSw.cpp.
I think this is an accidental left over. After removing this I get the following error.

Compiling .pioenvs\huzzah\lib\BME280\BME280SpiSw.o
.piolibdeps\BME280\src\BME280SpiSw.cpp:155:101: error: default argument given for parameter 5 of 'BME280SpiSw::BME280SpiSw(uint8_t, uint8_t, uint8_t, uint8_t, 
uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)' [-fpermissive]

This can be fixed by removing the defaults from the .cpp file, since they are already in the .h file.
After this cleanup it compiles without any issues.

Linker error in BME_280_BRZO_I2C_Test.ino

Actual behavior

sketch/BME_280_BRZO_I2C_Test.ino.cpp.o: In function `loop':
/home/user/Arduino/libraries/BME280/examples/BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino:94: undefined reference to `BME280I2C_BRZO::BME280I2C_BRZO(BME280I2C_BRZO::Settings const&)'
sketch/BME_280_BRZO_I2C_Test.ino.cpp.o: In function `__static_initialization_and_destruction_0':
/home/user/Arduino/libraries/BME280/examples/BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino:97: undefined reference to `BME280I2C_BRZO::BME280I2C_BRZO(BME280I2C_BRZO::Settings const&)'
collect2: error: ld returned 1 exit status

Steps to reporduce the behavior

Compile BME_280_BRZO_I2C_Test.ino.

Temperature question

Hi! First of all thanks for this library, it's a great job you did here!

I just wanted to ask, since in my experience the BME reads temperature a bit higher than some other sensors, if you compensate for that in the library?

I'm asking because at the moment I'm using a -2°C offset in the php file that fetches the data from my database but I noticed that when I changed to your library from the Sparkfun one I got a drop in the temperature readings - so it seems your library is closer to the "real" values and I might need to adjust my offset.

Thanks, Alex

First read after reset always 28.82 °C 81732.34 Pa

Sketch:

#include <Wire.h>
#include <BME280.h>
#include <BME280I2C.h>

BME280I2C bme;

void setup() { 
  Serial.begin(115200);

  pinMode(17, OUTPUT);
  digitalWrite(17, 1);
  delay(50);

  Serial.println(F("Starting I2C"));
  Wire.begin(2,4); // SDA = GPIO2, SCL = GPIO4

  while (!bme.begin()) {
    Serial.println(F("Could not find BMx280 sensor!"));
    delay(500);
  }

  switch(bme.chipModel())
  {
    case BME280::ChipModel_BME280:
      Serial.println(F("Found BME280 sensor, measuring temperature, humidity and pressure"));
    break;
    case BME280::ChipModel_BMP280:
      Serial.println("Found BMP280 sensor, measuring temperature and pressure only");
    break;
    default:
      Serial.println("ERROR: Found unknown sensor");
  }
}

void loop() {
  float temperature = 0;
  float humidity = 0;
  float pressure = 0;
  
  bme.read(pressure, temperature, humidity, BME280::TempUnit_Celsius, BME280::PresUnit_Pa);

  Serial.print(temperature);
  Serial.print(" °C ");
  Serial.print(pressure);
  Serial.print(" Pa");
  Serial.println("");
  
  delay(500);
}

Output:

Starting I2C
Found BMP280 sensor, measuring temperature and pressure only
28.82 °C 81732.34 Pa
25.78 °C 100944.22 Pa
25.79 °C 100947.60 Pa
25.78 °C 100943.45 Pa
25.78 °C 100944.22 Pa
25.78 °C 100944.22 Pa

Do mMultiple Sensors

Do multiple sensors get their own calibration values?
Or do they all use the same set?

PS: Why cant I edit the title.... urgh... sorry.

Absolute humidity measurement

Hi all,

as I am new to arduino and BME280 world I am not sure if my question I should ask under "Issues" or somwhere else, but in case I am on right place my question would be how to retrieve absolute humidity using this BME280 ? In library "finitespace/BME280" is mention only relative humidity, right ?
Thanks!

cheers,
Milan

Use of the functions

Can you please explain how I can use setSettings to change the mode of the BME280. I guess was
bme.setSettings("Mode_Sleep") but the IDE knows that this is not valid. How do you do it?

No Humidity Data?

I have a BME that seems to report temperature and atmospheric data without issue, but humidity data does not get reported. Any thoughts? I'm using the BME_280_I2C_Test code.

Here's the Serial output:

Temp: 27.22⸮C Humidity: 0.00% RH Pressure: 29.86 atm Altitude: 18.16m Dew point: nan⸮C

SPI Support still missing?

I tested a few librarys, they all lack features of the chip. This is the best one but it lacks SPI support...
Sparkfuns has a low resolution output for some reason while adafruits library cant be set to use any oversampling etc.

U mentioned adding that in the other issue, that would be really great. Otherwise I have to stick to adafruits very basic library...

Also, to have a better overview of the options:

BME280 bme(1, 2, 5, 3, 7, 4);
// 1 = oversample pressure ×1
// 2 = oversample temperature ×2
// 5 = oversample humidity ×16
// 3 = forced readout (1+2=normal, 0=sleep)
// 7 = 20ms sleeptime
// 4 = filter x16

And a list of the options:
// 0 = no oversampling
// 1 = 1x
// 2 = 2x
// 3 = 4x
// 4 = 8x
// 5 = 16x

// 0 = Sleep mode
// 1 or 2 = Forced mode
// 3 = Normal mode

// 0 = 0,5ms
// 6 = 10ms
// 7 = 20ms
// 1 = 62,5ms
// 2 = 125ms
// 3 = 250ms
// 4 = 500ms
// 5 = 1000ms

// 0 = Filter off
// 1 = 2x
// 2 = 4x
// 3 = 8x
// 4 = 16x

Version 2.1.0

Version 1.0.0 works fine but the IDE keeps nagging me to update to the latest 2.1.0 version. This is what happens with 2.1.0:

Arduino: 1.6.13 (Windows 10), Board: "WeMos D1 R2 & mini, 80 MHz, 115200, 4M (3M SPIFFS)"

Build options changed, rebuilding all
C:\Users\Karl\OneDrive\Arduino\libraries\BME280\src\BME280SpiSw.cpp:36:29: fatal error: Adafruit_BMP280.h: No such file or directory

#include <Adafruit_BMP280.h>

                         ^

compilation terminated.

exit status 1
Error compiling for board WeMos D1 R2 & mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

getStatus function

we should add a getStatus function where we select which bit is returned from the register.

Platformio library version bump

Hi!

Would it be possible to bump up the version string in library.properties to 2.0.0 to match the latest release?

It seems that the version Platformio currently distributes is somehow broken as I get the following compile error:

BME280I2C.h:56:23: error: expected ')' before 'tosr'

By looking at the commits in this repository, it seems that the bug has already been fixed, but the updated version is not available from platformio. This might get resolved if the library version would be updated.

ARDUINO_ARCH_ESP8266 issue

Hello, can you please tell me why i cannot compile this code
...
#define ARDUINO_ARCH_ESP8266
#include <BME280I2C.h>
...
compile error:
: undefined reference to BME280I2C::begin()' : In function setup()':
: undefined reference to `BME280I2C::begin()'
: ld returned 1 exit status

if i comment the line #define ARDUINO_ARCH_ESP8266
everything it's compile OK

any advise please

1 sample/minute?

Shouldn't this line in BME280_Modes.ino read 1 sample/second or is it really 1 minute? I am using this mode and seeing 1 sample/second.

//BME280I2C bme; // Weather Monitoring : forced mode, 1 sample/minute

'NAN' error running in Energia

Am trying to run the program in energia and am getting the following error.
BME_280_I2C_Test:78: error: 'NAN' was not declared in this scope
exit status 1
'NAN' was not declared in this scope.

Error: no matching function for call to 'BME280::BME280()'

I'm trying to use the Wemos-D1-Mini-BME280-Weather-Station project . When compiling in Arduino IDE 1.8.5 I get the following errors:

Arduino:1.8.5 (Windows 10), Płytka:"WeMos D1 mini Pro, 80 MHz, 16M (15M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

In file included from C:\Users\rober\Documents\Arduino\meteo\meteo.ino:14:0:

settings.h:21: error: no matching function for call to 'BME280::BME280()'

BME280 mySensor; // This can be tweaked, refer to https://github.com/finitespace/BME280 for details

sketch\settings.h:21:8: note: candidates are:

In file included from C:\Users\rober\Documents\Arduino\meteo\meteo.ino:7:0:

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:157:4: note: BME280::BME280(const BME280::Settings&)

BME280(

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:157:4: note: candidate expects 1 argument, 0 provided

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:43:7: note: constexpr BME280::BME280(const BME280&)

class BME280

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:43:7: note: candidate expects 1 argument, 0 provided

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:43:7: note: constexpr BME280::BME280(BME280&&)

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:43:7: note: candidate expects 1 argument, 0 provided

In file included from C:\Users\rober\Documents\Arduino\meteo\meteo.ino:14:0:

settings.h:21: error: cannot declare variable 'mySensor' to be of abstract type 'BME280'

BME280 mySensor; // This can be tweaked, refer to https://github.com/finitespace/BME280 for details

In file included from C:\Users\rober\Documents\Arduino\meteo\meteo.ino:7:0:

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:43:7: note: because the following virtual functions are pure within 'BME280':

class BME280

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:274:17: note: virtual bool BME280::WriteRegister(uint8_t, uint8_t)

virtual bool WriteRegister(

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:280:17: note: virtual bool BME280::ReadRegister(uint8_t, uint8_t*, uint8_t)

virtual bool ReadRegister(

C:\Users\rober\Documents\Arduino\meteo\meteo.ino: In function 'void loop()':

meteo:74: error: no matching function for call to 'BME280::ReadData(float&, float&, float&, bool, int)'

mySensor.ReadData(pressureBuffer[bufferposition], tempBuffer[bufferposition], humidityBuffer[bufferposition], true, 0);

C:\Users\rober\Documents\Arduino\meteo\meteo.ino:74:120: note: candidate is:

In file included from C:\Users\rober\Documents\Arduino\meteo\meteo.ino:7:0:

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:315:9: note: bool BME280::ReadData(int32_t*)

bool ReadData(

C:\Users\rober\Documents\Arduino\libraries\BME280_finitespace\src/BME280.h:315:9: note: candidate expects 1 argument, 5 provided

exit status 1
no matching function for call to 'BME280::BME280()'

I am very beginner, please help me solve the problem.

Multiply sensors

Hi together,

is there any possibility to have 2 or more sensor in parallel connected, so to be able to masure on two different point humidity at the same time ? If yes, how to distinguish between sensors ? It seems that all are having address 0x76 per default.

reards,
Milan

extend Initialize()

if we initialize the sensor we must take care of the sensor values. The user should not be bothered with handling the device in the right way, if the user wants a true measurement, they should get it. #59

We need to add at least one measurement (if forced mode is active). But in general we should use the table 6 'filter settings' to force a count of measurements before the user get control.

Efficiency of heatindex calculation method

Calculation of the heatindex I believe works correctly, but I guess the function is not efficiently written. I'd recommend

  1. If necessary, convert the temperature to a opposite units and stop thinking which of coefficients tables to use. Perhaps it will reduce the code size and increase the speed.

  2. Do not use the stack or other RAM memory for the coefficients. Write coefficients directly into formulas. It could save up to (2tables * 9coefficients * sizeof (float))= 72B of precious RAM.

  3. Perhaps it is possible to find a calculation method that will not be limited to 26.7 °C.

  4. The function returns float, but in Readme is erroneously written int.

I apologize for the delayed reaction - only a very short time has elapsed since pull request to merge...

consider changing Initialize() to public for bme280 forced mode

The forced mode of the bme280 allows a one shot read of the bme280 values (temp, humidity, etc).

The forced mode is selected in the constructor. The constructor calls Initialize() and sets forced mode (if the user set it to 1).

If that is the case, then the first read will give the values and put the bme280 in sleep mode (that is the way forced mode works).

The problem is that forced mode needs to be setted again to be able to be used again. It is resetted every read. The only way to do this is to call "WriteRegister(CONFIG_ADDR, config);" again.

Today it is called only at the constructor, which calls Initialize();

That is why I suggest to move in both I2C and Spi .h header files the Initialize() to "public:", so after a call to read we can call Initialize() again to set again forced mode and continue with another read and so forth.

That is the easy way. It works. I tested it.

Another more complicated way would be to handle it internally, with a flag somewhere, for every read, if the bme280 constructor setted forced mode, set it again before each read.

Error on default startup

Hi,

I'm an avg user, so this could be something I'm doing. But here's what's happening.

  1. Downloaded from gitHub.
  2. Unzipped into /Libraries location
  3. Opened "BME280"BME.ino"
  4. Verify/Compiled and received the following errors.

If you have a chance, sure could use to know if this is something I did/didn't do, something wrong with my setup, etc. Other sketches work fine i.e Sparkfun, Adafruit, etc. Wanted to try yours considering the functions you created.

Thanks,
Steve


Arduino: 1.8.0 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

C:\Users\Steve\Documents\Arduino\libraries\BME280\examples\BME280_Modes\BME280_Modes.ino: In function 'void printBME280Data(Stream*)':

BME280_Modes:96: error: no matching function for call to 'BME280I2C::ReadData(float&, float&, float&, uint8_t&, bool&)'

bme.ReadData(pres, temp, hum, pressureUnit, metric); // Parameters: (float& pressure, float& temp, float& humidity, bool hPa = true, bool celsius = false)

                                                 ^

C:\Users\Steve\Documents\Arduino\libraries\BME280\examples\BME280_Modes\BME280_Modes.ino:96:53: note: candidate is:

In file included from C:\Users\Steve\Documents\Arduino\libraries\BME280\examples\BME280_Modes\BME280_Modes.ino:26:0:

C:\Users\Steve\Documents\Arduino\libraries\BME280\src/BME280I2C.h:53:16: note: virtual bool BME280I2C::ReadData(int32_t*)

virtual bool ReadData(int32_t data[8]);

            ^

C:\Users\Steve\Documents\Arduino\libraries\BME280\src/BME280I2C.h:53:16: note: candidate expects 1 argument, 5 provided

C:\Users\Steve\Documents\Arduino\libraries\BME280\examples\BME280_Modes\BME280_Modes.ino: In function 'void printBME280CalculatedData(Stream*)':

BME280_Modes:117: error: 'class BME280I2C' has no member named 'CalculateAltitude'

float altitude = bme.CalculateAltitude(metric);

                    ^

exit status 1
no matching function for call to 'BME280I2C::ReadData(float&, float&, float&, uint8_t&, bool&)'


Change SDA/SCL

Hi,

I note at the end of the file BME280I2C.h:

#if defined(ARDUINO_ARCH_ESP8266)
/* ==== On esp8266 it is possible to define I2C pins ==== */
bool begin(int SDA, int SCL);
#endif

I wanted like to use this facility to change the SDA/SCL pins used on my ESP8266. I have tried adding #defines at the top of my main.cpp (Am using PlatformIO) which compiled but didn't seem to make any difference in that the BME was still being read on GPIO 4/5.

I did work out how to do this in the end... In the .platformio/packages/framework-arduinoespressif8266/variants/ directory are header files for all the different board types. Once I had worked out which board I was using - it was called nodemcu - (I had actually chosen "Espressif ESP8266 ESP-12E" from the Project builder in PlatformIO) I could set the pins in the appropriate pins_arduino.h file.

I now have my BME280 being read on GPIO 12 & 14 :-)

Maybe this info will help someone else.

Thanks for a cool library.

Help wanted...

Hi Tyler.

Thanks for putting this together. Works like a champ. I'm in my first weekend messing with the world of Arduino. So far, I've gotten: 2 nRF24L01+ to talk, the DHT-11 to return data, the BME280 to return data(thanks to your library and example sketch), and all on Pro Mini knockoffs. My question is this.

How (or where) do I change the units for the pressure here?
/* ==== Functions ==== /
void printBME280Data(Stream
client){
float temp(NAN), hum(NAN), pres(NAN);
uint8_t pressureUnit(3); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
bme.ReadData(pres, temp, hum, metric, pressureUnit); // Parameters: (float& pressure, float& temp, float& humidity, bool hPa = true, bool celsius = false)

Specifically, I'm lost as to where to put "B010" in the code.
Also, not sure what the " uint8_t pressureUnit(3); " is doing.

I've spent most of the weekend reading arduino.cc learning resources, and scouring google for explanations.

FWIW, I'm experienced with wiring, basic electronics, and hardware, but a total noob with c++.
My only coding experience has been Apple BASIC in Jr. High, and dabbling in VB for M$ Office.

Any advice?
Thanks again for writing this library!

Error compiling 'BME_280_BRZO_I2C_Test.ino'

Process:

  • Unzip arduino-1.8.4 to C:\
  • Create C:\arduino-1.8.4\portable
  • Add ESP8266 board manager URL, install ESP8266 board support, and select NodeMCU 1.0 (ESP-12E Module) from Board Manager
  • Install library Brzo I2C Version 1.31 from Library Manager
  • Install library BME280 Version 2.2.0 from Library Manager
  • Open example BME280_BRZO_I2C_Test
  • Run "Verify" and the following error occurs:
Arduino: 1.8.4 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

Archiving built core (caching) in: C:\Users\<user>\AppData\Local\Temp\arduino_cache_594038\core\core_esp8266_esp8266_nodemcuv2_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_8ee5fab911ac50cf47efcbc596507c23.a
sketch\BME_280_BRZO_I2C_Test.ino.cpp.o: In function `loop':

C:\arduino-1.8.4\portable\sketchbook\libraries\BME280\examples\BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino:84: undefined reference to `BME280I2C_BRZO::BME280I2C_BRZO(BME280I2C_BRZO::Settings const&)'

sketch\BME_280_BRZO_I2C_Test.ino.cpp.o: In function `__static_initialization_and_destruction_0':

C:\arduino-1.8.4\portable\sketchbook\libraries\BME280\examples\BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino:87: undefined reference to `BME280I2C_BRZO::BME280I2C_BRZO(BME280I2C_BRZO::Settings const&)'

sketch\BME_280_BRZO_I2C_Test.ino.cpp.o: In function `printBME280Data(Stream*)':

C:\arduino-1.8.4\portable\sketchbook\libraries\BME280\examples\BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino:88: undefined reference to `BME280I2C_BRZO::begin()'

sketch\BME_280_BRZO_I2C_Test.ino.cpp.o: In function `setup':

C:\arduino-1.8.4\portable\sketchbook\libraries\BME280\examples\BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino:51: undefined reference to `BME280I2C_BRZO::begin()'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Typo?

pres = bme.pres()

'class BME280I2C' has no member named 'pres'

Inside BME280.c, your pres function is called press

Just so you know. Your README and KEYWORDS need updating, or the BME class.

SPI Mode Settings

Hello,

I'm playing with BME280 and this lib to get my project working. But, I'm running into difficulties.
Also, I apologize, because I'm quite a beginner at Arduino and BME.

My project consist of a BME280 connected to an Arduino Pro Mini using SPI interface.
The basic setting are perfecly working. Now Iwould like to play with modes Setting. So I inspired myself of the I2C example :

BME280I2C::Settings settings(
BME280::OSR_X1,
BME280::OSR_X1,
BME280::OSR_X1,
BME280::Mode_Forced,
BME280::StandbyTime_1000ms,
BME280::Filter_Off,
BME280::SpiEnable_False,
BME280I2C::I2CAddr_0x76 // I2C address. I2C specific.
);
=> modified to this for SPI
#define DEVICE_PIN 9
BME280Spi::Settings settings(
BME280::OSR_X1,
BME280::OSR_X1,
BME280::OSR_X1,
BME280::Mode_Forced,
BME280::StandbyTime_1000ms,
BME280::Filter_Off,
BME280::SpiEnable_True,
DEVINCE_PIN // SPI Device PIN
);

This is not compiling arguing that 1 parameter is expected but 8 are provided.
Maybe you can help me understanding the way to declare settings with SPI ? An example would be great !

So then I tried another way to play with settings and I use this method :

// Change some settings before using.
settings.tempOSR = BME280::OSR_X4;
bme.setSettings(settings);

This is working OK. Even all OSR_X1 to X16 are working but not this even if it's documented:

// Change some settings before using.
settings.tempOSR = BME280::OSR_Off;
bme.setSettings(settings);

Compiling says : OSR_Off is not part of BME280

Yep, I would like to disable some measurement of the BME280 in order to save power, and I won't use all three measurement available on the BME.

Thanks for your help ! :)

Doesn´t show humidity

I use this library with Arduino nano, it works fine except humidity - it shows all time 0,00%. Is problem on my module?
Thanks.

Connecting multiple BME280s

Thanks a bunch for this awesome library!

Well, problem is as simple as that... I'm trying to gather data off of two of these. The code works for one, but I have no idea how to connect a second one up. :) Thanks!!!

compiler warning:

Expected behavior

return a bool from:

  • bool BME280::InitializeFilter()
  • bool BME280::WriteSettings()

Actual behavior

/Arduino/libraries/BME280/src/BME280.cpp: In member function 'bool BME280::InitializeFilter()':
/Arduino/libraries/BME280/src/BME280.cpp:85:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
/Arduino/libraries/BME280/src/BME280.cpp: In member function 'bool BME280::WriteSettings()':
/Arduino/libraries/BME280/src/BME280.cpp:122:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }

Steps to reporduce the behavior

compile the master branch

suggested solution

bool BME280::InitializeFilter()

  1. read Data from Sensor to get individual boot up values
  2. Write Settings
  3. read Data from Sensor to get current values
  4. compare them

bool BME280::WriteSettings()
0. Write Settings

  1. read Settings
  2. compare them
  3. return result

-- OR --
return the return value from used I2C functions

compile errors

Sorry for the newbie question. I've installed the lib per the README and I'm using ID 1.6.5 but I'm getting compilation error using the test example:

Arduino: 1.6.5 (Mac OS X), Board: "Arduino Uno"

Build options changed, rebuilding all
Using library BME280 in folder: /Applications/Arduino.app/Contents/Java/libraries/BME280 (legacy)

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Applications/Arduino.app/Contents/Java/libraries/BME280 /var/folders/cf/6c8fqtkj4b91nhzcrfhlzz5h0000gn/T/build8708549420658519769.tmp/BME280_Test.cpp -o /var/folders/cf/6c8fqtkj4b91nhzcrfhlzz5h0000gn/T/build8708549420658519769.tmp/BME280_Test.cpp.o
In file included from BME280_Test.ino:37:0:
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:48:3: error: 'uint8_t' does not name a type
uint8_t tempOversamplingRate, humidityOversamplingRate, pressureOversamplingRate; // B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16
^
In file included from BME280_Test.ino:37:0:
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:49:3: error: 'uint8_t' does not name a type
uint8_t mode; // Sleep = B00, Normal = B01 and B10, Forced = B11
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:50:3: error: 'uint8_t' does not name a type
uint8_t standbyTime; // B000 = 0.5ms, B001 = 62.5ms, B010 = 125ms, B011 = 250ms, B100 = 250ms, B101 = 1000ms, B110 = 10ms, B111 = 20ms
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:51:3: error: 'uint8_t' does not name a type
uint8_t filter; // B000 = off, B001 = 2, B010 = 4, B011 = 8, B100/other = 16
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:52:3: error: 'uint8_t' does not name a type
uint8_t controlHumidity; // ctrl_hum register. (ctrl_hum[2:0] = Humidity oversampling rate.)
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:53:3: error: 'uint8_t' does not name a type
uint8_t controlMeasure; // ctrl_meas register. (ctrl_meas[7:5] = temperature oversampling rate, ctrl_meas[4:2] = pressure oversampling rate, ctrl_meas[1:0] = mode.)
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:54:3: error: 'uint8_t' does not name a type
uint8_t config; // config register. (config[7:5] = standby time, config[4:2] = filter, ctrl_meas[0] = spi enable.)
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:55:3: error: 'uint8_t' does not name a type
uint8_t bme_280_addr;
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:56:3: error: 'uint8_t' does not name a type
uint8_t dig[32];
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:60:22: error: 'uint8_t' has not been declared
void WriteRegister(uint8_t addr, uint8_t data);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:60:36: error: 'uint8_t' has not been declared
void WriteRegister(uint8_t addr, uint8_t data);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:66:17: error: 'int32_t' has not been declared
bool ReadData(int32_t data[8]);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:69:30: error: 'int32_t' has not been declared
float CalculateTemperature(int32_t raw, int32_t& t_fine, bool celsius = true);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:69:43: error: 'int32_t' has not been declared
float CalculateTemperature(int32_t raw, int32_t& t_fine, bool celsius = true);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:72:27: error: 'int32_t' has not been declared
float CalculateHumidity(int32_t raw, int32_t t_fine);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:72:40: error: 'int32_t' has not been declared
float CalculateHumidity(int32_t raw, int32_t t_fine);
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:75:27: error: 'int32_t' has not been declared
float CalculatePressure(int32_t raw, int32_t t_fine, uint8_t unit = 0x0); // unit: B000/other = Pa, B001 = hPa, B010 = inHg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:75:40: error: 'int32_t' has not been declared
float CalculatePressure(int32_t raw, int32_t t_fine, uint8_t unit = 0x0); // unit: B000/other = Pa, B001 = hPa, B010 = inHg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:75:56: error: 'uint8_t' has not been declared
float CalculatePressure(int32_t raw, int32_t t_fine, uint8_t unit = 0x0); // unit: B000/other = Pa, B001 = hPa, B010 = inHg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:79:18: error: expected ')' before 'tosr'
BME280(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3,
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:90:22: error: 'uint8_t' has not been declared
float ReadPressure(uint8_t unit = 0x0); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
^
/Applications/Arduino.app/Contents/Java/libraries/BME280/BME280.h:96:85: error: 'uint8_t' has not been declared
void ReadData(float& pressure, float& temp, float& humidity, bool metric = true, uint8_t p_unit = 0x0);
^
Error compiling.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.