Adafruit BMP280 Library
Classes | Public Types | Public Member Functions | List of all members
Adafruit_BMP280 Class Reference

#include <Adafruit_BMP280.h>

Public Types

enum  sensor_sampling {
  SAMPLING_NONE = 0x00, SAMPLING_X1 = 0x01, SAMPLING_X2 = 0x02, SAMPLING_X4 = 0x03,
  SAMPLING_X8 = 0x04, SAMPLING_X16 = 0x05
}
 
enum  sensor_mode { MODE_SLEEP = 0x00, MODE_FORCED = 0x01, MODE_NORMAL = 0x03, MODE_SOFT_RESET_CODE = 0xB6 }
 
enum  sensor_filter {
  FILTER_OFF = 0x00, FILTER_X2 = 0x01, FILTER_X4 = 0x02, FILTER_X8 = 0x03,
  FILTER_X16 = 0x04
}
 
enum  standby_duration {
  STANDBY_MS_1 = 0x00, STANDBY_MS_63 = 0x01, STANDBY_MS_125 = 0x02, STANDBY_MS_250 = 0x03,
  STANDBY_MS_500 = 0x04, STANDBY_MS_1000 = 0x05, STANDBY_MS_2000 = 0x06, STANDBY_MS_4000 = 0x07
}
 

Public Member Functions

 Adafruit_BMP280 (TwoWire *theWire=&Wire)
 BMP280 constructor using i2c. More...
 
 Adafruit_BMP280 (int8_t cspin, SPIClass *theSPI=&SPI)
 BMP280 constructor using hardware SPI. More...
 
 Adafruit_BMP280 (int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
 BMP280 constructor using bitbang SPI. More...
 
bool begin (uint8_t addr=BMP280_ADDRESS, uint8_t chipid=BMP280_CHIPID)
 
void reset (void)
 Resets the chip via soft reset.
 
uint8_t getStatus (void)
 Gets the most recent sensor event from the hardware status register. More...
 
uint8_t sensorID (void)
 
float readTemperature ()
 
float readPressure (void)
 
float readAltitude (float seaLevelhPa=1013.25)
 Calculates the approximate altitude using barometric pressure and the supplied sea level hPa as a reference. More...
 
float seaLevelForAltitude (float altitude, float atmospheric)
 
float waterBoilingPoint (float pressure)
 calculates the boiling point of water by a given pressure More...
 
bool takeForcedMeasurement ()
 Take a new measurement (only possible in forced mode) More...
 
Adafruit_Sensor * getTemperatureSensor (void)
 Gets an Adafruit Unified Sensor object for the temp sensor component. More...
 
Adafruit_Sensor * getPressureSensor (void)
 Gets an Adafruit Unified Sensor object for the pressure sensor component. More...
 
void setSampling (sensor_mode mode=MODE_NORMAL, sensor_sampling tempSampling=SAMPLING_X16, sensor_sampling pressSampling=SAMPLING_X16, sensor_filter filter=FILTER_OFF, standby_duration duration=STANDBY_MS_1)
 

Detailed Description

Driver for the Adafruit BMP280 barometric pressure sensor.

Member Enumeration Documentation

◆ sensor_sampling

Oversampling rate for the sensor.

Enumerator
SAMPLING_NONE 

No over-sampling.

SAMPLING_X1 

1x over-sampling.

SAMPLING_X2 

2x over-sampling.

SAMPLING_X4 

4x over-sampling.

SAMPLING_X8 

8x over-sampling.

SAMPLING_X16 

16x over-sampling.

◆ sensor_mode

Operating mode for the sensor.

Enumerator
MODE_SLEEP 

Sleep mode.

MODE_FORCED 

Forced mode.

MODE_NORMAL 

Normal mode.

MODE_SOFT_RESET_CODE 

Software reset.

◆ sensor_filter

Filtering level for sensor data.

Enumerator
FILTER_OFF 

No filtering.

FILTER_X2 

2x filtering.

FILTER_X4 

4x filtering.

FILTER_X8 

8x filtering.

FILTER_X16 

16x filtering.

◆ standby_duration

Standby duration in ms

Enumerator
STANDBY_MS_1 

1 ms standby.

STANDBY_MS_63 

62.5 ms standby.

STANDBY_MS_125 

125 ms standby.

STANDBY_MS_250 

250 ms standby.

STANDBY_MS_500 

500 ms standby.

STANDBY_MS_1000 

1000 ms standby.

STANDBY_MS_2000 

2000 ms standby.

STANDBY_MS_4000 

4000 ms standby.

Constructor & Destructor Documentation

◆ Adafruit_BMP280() [1/3]

Adafruit_BMP280::Adafruit_BMP280 ( TwoWire *  theWire = &Wire)

BMP280 constructor using i2c.

Parameters
*theWireoptional wire

◆ Adafruit_BMP280() [2/3]

Adafruit_BMP280::Adafruit_BMP280 ( int8_t  cspin,
SPIClass *  theSPI = &SPI 
)

BMP280 constructor using hardware SPI.

Parameters
cspincs pin number
theSPIoptional SPI object

◆ Adafruit_BMP280() [3/3]

Adafruit_BMP280::Adafruit_BMP280 ( int8_t  cspin,
int8_t  mosipin,
int8_t  misopin,
int8_t  sckpin 
)

BMP280 constructor using bitbang SPI.

Parameters
cspinThe pin to use for CS/SSEL.
mosipinThe pin to use for MOSI.
misopinThe pin to use for MISO.
sckpinThe pin to use for SCK.

Member Function Documentation

◆ begin()

bool Adafruit_BMP280::begin ( uint8_t  addr = BMP280_ADDRESS,
uint8_t  chipid = BMP280_CHIPID 
)

Initialises the sensor.

Parameters
addrThe I2C address to use (default = 0x77)
chipidThe expected chip ID (used to validate connection).
Returns
True if the init was successful, otherwise false.

◆ getStatus()

uint8_t Adafruit_BMP280::getStatus ( void  )

Gets the most recent sensor event from the hardware status register.

Returns
Sensor status as a byte.

◆ sensorID()

uint8_t Adafruit_BMP280::sensorID ( void  )

Returns Sensor ID for diagnostics

Returns
0x61 for BME680, 0x60 for BME280, 0x56, 0x57, 0x58 for BMP280

◆ readTemperature()

float Adafruit_BMP280::readTemperature ( )

Reads the temperature from the device.

Returns
The temperature in degrees celsius.

◆ readPressure()

float Adafruit_BMP280::readPressure ( void  )

Reads the barometric pressure from the device.

Returns
Barometric pressure in Pa.

◆ readAltitude()

float Adafruit_BMP280::readAltitude ( float  seaLevelhPa = 1013.25)

Calculates the approximate altitude using barometric pressure and the supplied sea level hPa as a reference.

Parameters
seaLevelhPaThe current hPa at sea level.
Returns
The approximate altitude above sea level in meters.

◆ seaLevelForAltitude()

float Adafruit_BMP280::seaLevelForAltitude ( float  altitude,
float  atmospheric 
)

Calculates the pressure at sea level (QNH) from the specified altitude, and atmospheric pressure (QFE).

Parameters
altitudeAltitude in m
atmosphericAtmospheric pressure in hPa
Returns
The approximate pressure in hPa

◆ waterBoilingPoint()

float Adafruit_BMP280::waterBoilingPoint ( float  pressure)

calculates the boiling point of water by a given pressure

Parameters
pressurepressure in hPa
Returns
temperature in °C

◆ takeForcedMeasurement()

bool Adafruit_BMP280::takeForcedMeasurement ( )

Take a new measurement (only possible in forced mode)

Returns
true if successful, otherwise false

◆ getTemperatureSensor()

Adafruit_Sensor * Adafruit_BMP280::getTemperatureSensor ( void  )

Gets an Adafruit Unified Sensor object for the temp sensor component.

Returns
Adafruit_Sensor pointer to temperature sensor

◆ getPressureSensor()

Adafruit_Sensor * Adafruit_BMP280::getPressureSensor ( void  )

Gets an Adafruit Unified Sensor object for the pressure sensor component.

Returns
Adafruit_Sensor pointer to pressure sensor

◆ setSampling()

void Adafruit_BMP280::setSampling ( sensor_mode  mode = MODE_NORMAL,
sensor_sampling  tempSampling = SAMPLING_X16,
sensor_sampling  pressSampling = SAMPLING_X16,
sensor_filter  filter = FILTER_OFF,
standby_duration  duration = STANDBY_MS_1 
)

Sets the sampling config for the device.

Parameters
modeThe operating mode of the sensor.
tempSamplingThe sampling scheme for temp readings.
pressSamplingThe sampling scheme for pressure readings.
filterThe filtering mode to apply (if any).
durationThe sampling duration.

The documentation for this class was generated from the following files: