BoschBMP3xx class

The Sensor sub-class for the Bosch BMP3xx.

Base classes

class Sensor
The "Sensor" class is used for all sensor-level operations - waking, sleeping, and taking measurements.

Constructors, destructors, conversion operators

BoschBMP3xx(int8_t powerPin, Mode mode = FORCED_MODE, Oversampling pressureOversample = OVERSAMPLING_X16, Oversampling tempOversample = OVERSAMPLING_X2, IIRFilter filterCoeff = IIR_FILTER_OFF, TimeStandby timeStandby = TIME_STANDBY_10MS, uint8_t i2cAddressHex = 0x76) explicit
Construct a new Bosch BMP3xx object using the primary hardware I2C instance.
~BoschBMP3xx()
Destroy the Bosch BMP3xx object.

Public functions

bool wake(void) -> bool override
Wake the sensor up, if necessary. Do whatever it takes to get a sensor in the proper state to begin a measurement.
bool setup(void) -> bool override
Do any one-time preparations needed before the sensor will be able to take readings.
String getSensorLocation(void) -> String override
Get the pin or connection location between the mcu and the sensor.
bool startSingleMeasurement(void) -> bool override
Tell the sensor to start a single measurement, if needed.
bool addSingleMeasurementResult(void) -> bool override
Get the results from a single measurement.

Function documentation

BoschBMP3xx::BoschBMP3xx(int8_t powerPin, Mode mode = FORCED_MODE, Oversampling pressureOversample = OVERSAMPLING_X16, Oversampling tempOversample = OVERSAMPLING_X2, IIRFilter filterCoeff = IIR_FILTER_OFF, TimeStandby timeStandby = TIME_STANDBY_10MS, uint8_t i2cAddressHex = 0x76) explicit

Construct a new Bosch BMP3xx object using the primary hardware I2C instance.

Parameters
powerPin

The pin on the mcu controlling power to the BMP3XX Use -1 if it is continuously powered.

  • The BMP3xx requires a 1.7 - 3.6V power source
mode

Data sampling mode
Possible values are:

  • FORCED_MODE - a single measurement is made upon request and the sensor immediately returns to sleep. This mode should be used if you are stopping power to the sensor between readings. You should not use this mode if you wish to use the sensor's on-board IIR filter.
  • NORMAL_MODE - the sensor alteranates between sampling and sleeping at intervals set by the sensor output data rate, results can be read whenever needed. This mode should not be used if you will stop power to the sensor between readings. If you wish to use the sensor's on-board filtering, you should use normal mode.
pressureOversample

Pressure oversampling setting
Possible values are:

  • OVERSAMPLING_SKIP
  • OVERSAMPLING_X2
  • OVERSAMPLING_X4,
  • OVERSAMPLING_X8
  • OVERSAMPLING_X16,
  • OVERSAMPLING_X32
tempOversample Temperature oversampling setting
Possible values are the same as those for pressureOversample. Using temperature oversampling above X2 is not recommended as it does not further improve pressure data quality.
filterCoeff

Coefficient of the infinite impulse response (IIR) filter (in samples).
This is number of past samples considered in calculating the current filtered value. This setting is ignored if the sensor will not be continuously powered. This only recommended when operating in "normal" sampling mode.
Possible values are:

  • IIR_FILTER_OFF (no filtering)
  • IIR_FILTER_1,
  • IIR_FILTER_3
  • IIR_FILTER_7,
  • IIR_FILTER_15
  • IIR_FILTER_31,
  • IIR_FILTER_63
  • IIR_FILTER_127
timeStandby

Standby time between measurements when continuously powered and operating in normal mode.
This is the inverse of the output data rate (ODR).
This setting is ignored when operating in forced mode.
Possible values are:

  • TIME_STANDBY_5MS (ODR = 200 Hz)
  • TIME_STANDBY_10MS (ODR = 100 Hz)
  • TIME_STANDBY_20MS (ODR = 50 Hz)
  • TIME_STANDBY_40MS (ODR = 25 Hz)
  • TIME_STANDBY_80MS (ODR = 12.5 Hz)
  • TIME_STANDBY_160MS (ODR = 6.25 Hz)
  • TIME_STANDBY_320MS (ODR = 3.125 Hz)
  • TIME_STANDBY_640MS (ODR = 1.5 Hz)
  • TIME_STANDBY_1280MS (~1.2 seconds, ODR = 0.78 Hz)
  • TIME_STANDBY_2560MS (~2.5 seconds, ODR = 0.39 Hz)
  • TIME_STANDBY_5120MS (~5 seconds, ODR = 0.2 Hz)
  • TIME_STANDBY_10240MS (~10 seconds, ODR = 0.1 Hz)
  • TIME_STANDBY_20480MS (~20 seconds, ODR = 0.05 Hz)
  • TIME_STANDBY_40960MS (~41 seconds, ODR = 0.025 Hz)
  • TIME_STANDBY_81920MS (~82 seconds or 1.4 minutes, ODR = 0.0125 Hz)
  • TIME_STANDBY_163840MS (~164 seconds or 2.7 minutes, ODR = 0.006 Hz)
  • TIME_STANDBY_327680MS (~5.5 minutes, ODR = 0.003 Hz)
  • TIME_STANDBY_655360MS (~11 minutes, ODR = 0.0015 Hz)
i2cAddressHex The I2C address of the BMP3xx; must be either 0x76 or 0x77. The default value is 0x76.

bool BoschBMP3xx::wake(void) override

Wake the sensor up, if necessary. Do whatever it takes to get a sensor in the proper state to begin a measurement.

Returns bool True if the wake function completed successfully.

Verifies that the power is on and updates the _sensorStatus. This also sets the _millisSensorActivated timestamp.


bool BoschBMP3xx::setup(void) override

Do any one-time preparations needed before the sensor will be able to take readings.

Returns bool True if the setup was successful.

This begins the Wire library (sets pin modes for I2C), reads calibration coefficients from the BMP3xx, and updates the _sensorStatus. The BMP3xx must be powered for setup.


String BoschBMP3xx::getSensorLocation(void) override

Get the pin or connection location between the mcu and the sensor.

Returns String Text describing how the sensor is attached to the mcu.

bool BoschBMP3xx::startSingleMeasurement(void) override

Tell the sensor to start a single measurement, if needed.

Returns bool True if the start measurement function completed successfully.

This also sets the _millisMeasurementRequested timestamp and updates the _sensorStatus.


bool BoschBMP3xx::addSingleMeasurementResult(void) override

Get the results from a single measurement.

Returns bool True if the function completed successfully.

This asks the sensor for a new result, verifies that it passes sanity range checks, and then adds the value to the result array.

This also un-sets the _millisMeasurementRequested timestamp (sets _millisMeasurementRequested to 0) and updates the _sensorStatus.