Skip to content

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bosch BME280 Arduino

Compile examples folder Spell Check Generate Doxygen Documentation

based on Bosch BME280_driver v3.5.1

BME280-module

List of content

About

The Bosch BME280 is an environmental sensor which is able to measure temperature, humidity and air pressure.

This library is based on the Bosch Sensortec BME280 driver API v3.5.1, and is intended to measure these environmental signals via I²C connection on an Arduino based or ESP based microcontroller.

The github repository of Bosch Sensortec is: Github BOSCH Sensor Driver

The website of the BME280 on Bosch Sensortec is: Bosch Sensortec BME280

Library Documentation

The functional documentation of this wrapper library you will find in the provided refman.pdf, or under github-pages github.io.

Functionality

The original Bosch driver is included in this package and it has not been modified in any way. The Bosch BME280 sensor do have 3 operation modes.

  1. Sleep mode - the sensor is in sleep mode after power on reset. No measurements are performed and power consumption is on minimum.
  2. Forced mode - one single measurement is performed and returns then to sleep mode. The measurements can be obtained from the data registers.
  3. Normal mode - cyclic measurements are performed. The measurements can be obtained from the data registers.

Sensor Settings

The sensor used three main settings to adapt the measurement campaign to your needs.

a) sensor mode setting with standby time
b) Oversampling setting
c) IIR-Filter setting

Sensor mode: see also chapter 3.4 in datasheet.
Defines if a measurement is performed only once (forced mode) or cyclic (normal mode). In normal mode the standby can be defined by the parameter standby time.

Oversampling setting: see also chapter 3.4.1 ...3.4.3 in datasheet.
With this setting you define how is the measurement done. No oversampling means the measurement is skipped, no measurement is done. Oversampling rates of x1...x16 defined how many measurements are taken.

IIR-Filter setting: see also chapter 3.4.4 in datasheet.
Defines the step response behaviour of the IIR-Filter

Namespace

This Bosch BME280 wrapper uses a namespace as BME so if you construct the object you have to call:

BME::Bosch_BME280 bme{BME280_I2C_ADDR_PRIM, 249.67F, false};

Methods

Public

The are the following public methods:

Constructor

You call the constructor with various parameters:

  • address of the BME280 (0x76 or 0x77)
  • altitude for the calculation of the sea level pressure
  • a Bool - true if use forced mode or false if use normal mode
Bosch_BME280(addr, altitude, forced_mode)

Init I²C and Sensor Init

begin()

Measurement

measure()

Data Query

These four methods returns the temperature, humidity and pressure in float.

getTemperature()
getHumidity()
getPressure()
getSealevelForAltitude()

Sensor Status

Also it is possible to get and set the sensor status.

int8_t status = getSensorStatus();
setSensorStatus(status);

Example

See also in:

#include <Arduino.h>
#include <Bosch_BME280_Arduino.h>

BME::Bosch_BME280 bme{BME280_I2C_ADDR_PRIM, 249.67F, true};

void setup() {
    Serial.begin(115200);
    while (!Serial) {
      yield();
    }

   // SDA, SCL needed for ESPs
#if defined (ESP8266)
  Wire.begin(SDA, SCL);
#elif defined (ESP32)
  Wire.setPins(SDA, SCL);
  Wire.begin();
#else
  Wire.begin();
#endif

    // init Bosch BME 280 Sensor
    if (bme.begin() != 0) {
      Serial.println("\n\t>>> ERROR: Init of Bosch BME280 Sensor failed! <<<");
    }
}

void loop() {
    static unsigned long tic {millis()};
    unsigned long ms = millis();
    if (ms - tic >= 2000) {
      tic = ms;
      bme.measure();
      Serial.print("\n\tTemperature:\t");
      Serial.println(bme.getTemperature());
      Serial.print("\tHumidity:\t");
      Serial.println(bme.getHumidity());
      Serial.print("\tPressure at NN:\t");
      Serial.println(bme.getSealevelForAltitude());
    }
}

Compatibility

Tested with:

  • Arduino Nano
  • ESP8266
  • ESP32
  • Arduino Nano 33 IOT

Copyright

The Files of the original Bosch BME280 driver API:

  • bme280.c
  • bme280.h
  • bme280_defs.h

are Copyright (c) 2013 - 2017 by Bosch Sensortec GmbH

back to top

About

Arduino wrapper class for the Bosch Sensortec BME280 driver API

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages