Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::BME280 Class Reference

#include <BME280.h>

Inheritance diagram for Boardcore::BME280:
Collaboration diagram for Boardcore::BME280:

Classes

union  BME280Comp
 
union  BME280Config
 

Public Types

enum  Oversampling {
  SKIPPED = 0x0 , OVERSAMPLING_1 = 0x1 , OVERSAMPLING_2 = 0x2 , OVERSAMPLING_4 = 0x3 ,
  OVERSAMPLING_8 = 0x4 , OVERSAMPLING_16 = 0x5
}
 
enum  Mode { SLEEP_MODE = 0x0 , FORCED_MODE = 0x1 , NORMAL_MODE = 0x3 }
 
enum  StandbyTime {
  STB_TIME_0_5 = 0x0 , STB_TIME_62_5 = 0x1 , STB_TIME_125 = 0x2 , STB_TIME_250 = 0x3 ,
  STB_TIME_500 = 0x4 , STB_TIME_1000 = 0x5 , STB_TIME_10 = 0x6 , STB_TIME_20 = 0x7
}
 
enum  FilterCoeff {
  FILTER_OFF = 0x0 , FILTER_COEFF_2 = 0x1 , FILTER_COEFF_4 = 0x2 , FILTER_COEFF_8 = 0x3 ,
  FILTER_COEFF_16 = 0x4
}
 
- Public Types inherited from Boardcore::Sensor< BME280Data >
using DataType
 

Public Member Functions

 BME280 (SPISlave spiSlave, BME280Config config=BME280_CONFIG_ALL_ENABLED)
 
bool init () override
 Initialize the device with the specified configuration.
 
void setSensorMode (Mode mode)
 Sets the sensor mode.
 
void setHumidityOversampling (Oversampling oversampling)
 Sets the oversampling for humidity readings, use SKIPPED to disable humidity sampling.
 
void setPressureOversampling (Oversampling oversampling)
 Sets the oversampling for pressure readings, use SKIPPED to disable pressure sampling.
 
void setTemperatureOversampling (Oversampling oversampling)
 Sets the oversampling for temperature readings, use SKIPPED to disable temperature sampling.
 
void setFilterCoeff (FilterCoeff filterCoeff)
 Sets the coefficient for the IIR filter (applied to temperature and pressure)
 
void setStandbyTime (StandbyTime standbyTime)
 Sets the standby time between readings in normal mode.
 
HumidityData readHumidity ()
 Reads only the humidity, does not set the configuration.
 
PressureData readPressure ()
 Reads only the pressure, does not set the configuration.
 
TemperatureData readTemperature ()
 Reads only the temperature, does not set the configuration.
 
unsigned int getMaxMeasurementTime ()
 
bool selfTest () override
 Reads the WHO AM I register.
 
- Public Member Functions inherited from Boardcore::Sensor< BME280Data >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual BME280Data getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
virtual ~AbstractSensor ()
 
SensorErrors getLastError ()
 Get last error for debugging purposes. Avoid silent fails.
 

Static Public Member Functions

static unsigned int calculateMaxMeasurementTime (BME280Config config)
 Maximum measurement time formula from datasheet page 51.
 

Static Public Attributes

static constexpr uint8_t REG_ID_VAL = 0x60
 Who am I value.
 
static const BME280Config BME280_DEFAULT_CONFIG
 Datasheet values for indoor navigation.
 
static const BME280Config BME280_CONFIG_ALL_ENABLED
 Temperature enabled in forced mode.
 
static const BME280Config BME280_CONFIG_TEMP_SINGLE
 

Protected Member Functions

BME280Data sampleImpl () override
 Read a data sample from the sensor. In case of errors, the method should return the last available correct sample.
 

Additional Inherited Members

- Protected Attributes inherited from Boardcore::Sensor< BME280Data >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 

Detailed Description

Definition at line 34 of file BME280.h.

Member Enumeration Documentation

◆ FilterCoeff

Enumerator
FILTER_OFF 

Filter off.

FILTER_COEFF_2 

Filter coefficient = 2.

FILTER_COEFF_4 

Filter coefficient = 4.

FILTER_COEFF_8 

Filter coefficient = 8.

FILTER_COEFF_16 

Filter coefficient = 16.

Definition at line 66 of file BME280.h.

◆ Mode

Enumerator
SLEEP_MODE 

Sleep mode.

FORCED_MODE 

Forced mode.

NORMAL_MODE 

Normal mode.

Definition at line 47 of file BME280.h.

◆ Oversampling

Enumerator
SKIPPED 

Skipped (output set to 0x8000)

OVERSAMPLING_1 

Oversampling x1.

OVERSAMPLING_2 

Oversampling x2.

OVERSAMPLING_4 

Oversampling x4.

OVERSAMPLING_8 

Oversampling x8.

OVERSAMPLING_16 

Oversampling x16.

Definition at line 37 of file BME280.h.

◆ StandbyTime

Enumerator
STB_TIME_0_5 

0.5 ms

STB_TIME_62_5 

62.5 ms

STB_TIME_125 

125 ms

STB_TIME_250 

250 ms

STB_TIME_500 

500 ms

STB_TIME_1000 

1000 ms

STB_TIME_10 

10 ms

STB_TIME_20 

20 ms

Definition at line 54 of file BME280.h.

Constructor & Destructor Documentation

◆ BME280()

Boardcore::BME280::BME280 ( SPISlave spiSlave,
BME280Config config = BME280_CONFIG_ALL_ENABLED )
explicit

Definition at line 50 of file BME280.cpp.

Member Function Documentation

◆ calculateMaxMeasurementTime()

unsigned int Boardcore::BME280::calculateMaxMeasurementTime ( BME280Config config)
static

Maximum measurement time formula from datasheet page 51.

Returns
Time in milliseconds

Definition at line 202 of file BME280.cpp.

◆ getMaxMeasurementTime()

unsigned int Boardcore::BME280::getMaxMeasurementTime ( )

Definition at line 209 of file BME280.cpp.

◆ init()

bool Boardcore::BME280::init ( )
overridevirtual

Initialize the device with the specified configuration.

Implements Boardcore::AbstractSensor.

Definition at line 55 of file BME280.cpp.

◆ readHumidity()

HumidityData Boardcore::BME280::readHumidity ( )

Reads only the humidity, does not set the configuration.

Definition at line 138 of file BME280.cpp.

◆ readPressure()

PressureData Boardcore::BME280::readPressure ( )

Reads only the pressure, does not set the configuration.

Definition at line 158 of file BME280.cpp.

◆ readTemperature()

TemperatureData Boardcore::BME280::readTemperature ( )

Reads only the temperature, does not set the configuration.

Definition at line 179 of file BME280.cpp.

◆ sampleImpl()

BME280Data Boardcore::BME280::sampleImpl ( )
overrideprotectedvirtual

Read a data sample from the sensor. In case of errors, the method should return the last available correct sample.

Returns
sensor data sample

Implements Boardcore::Sensor< BME280Data >.

Definition at line 216 of file BME280.cpp.

◆ selfTest()

bool Boardcore::BME280::selfTest ( )
overridevirtual

Reads the WHO AM I register.

Returns
True if everything ok

Implements Boardcore::AbstractSensor.

Definition at line 214 of file BME280.cpp.

◆ setFilterCoeff()

void Boardcore::BME280::setFilterCoeff ( FilterCoeff filterCoeff)

Sets the coefficient for the IIR filter (applied to temperature and pressure)

Definition at line 124 of file BME280.cpp.

◆ setHumidityOversampling()

void Boardcore::BME280::setHumidityOversampling ( Oversampling oversampling)

Sets the oversampling for humidity readings, use SKIPPED to disable humidity sampling.

Definition at line 103 of file BME280.cpp.

◆ setPressureOversampling()

void Boardcore::BME280::setPressureOversampling ( Oversampling oversampling)

Sets the oversampling for pressure readings, use SKIPPED to disable pressure sampling.

Definition at line 110 of file BME280.cpp.

◆ setSensorMode()

void Boardcore::BME280::setSensorMode ( Mode mode)

Sets the sensor mode.

Values:

  • SLEEP_MODE: No measurements are performed
  • FORCED_MODE: A single measurement is performed when this function writes the configuration, after the measurement the sensor return to sleep mode
  • NORMAL_MODE: Automated cycling between measurements, standby time can be set using setStandbyTime()

Definition at line 96 of file BME280.cpp.

◆ setStandbyTime()

void Boardcore::BME280::setStandbyTime ( StandbyTime standbyTime)

Sets the standby time between readings in normal mode.

Definition at line 131 of file BME280.cpp.

◆ setTemperatureOversampling()

void Boardcore::BME280::setTemperatureOversampling ( Oversampling oversampling)

Sets the oversampling for temperature readings, use SKIPPED to disable temperature sampling.

Definition at line 117 of file BME280.cpp.

Member Data Documentation

◆ BME280_CONFIG_ALL_ENABLED

const BME280::BME280Config Boardcore::BME280::BME280_CONFIG_ALL_ENABLED
static
Initial value:
0,
0,
0,
@ OVERSAMPLING_1
Oversampling x1.
Definition BME280.h:40
@ OVERSAMPLING_16
Oversampling x16.
Definition BME280.h:44
@ OVERSAMPLING_2
Oversampling x2.
Definition BME280.h:41
@ FILTER_COEFF_16
Filter coefficient = 16.
Definition BME280.h:72
@ NORMAL_MODE
Normal mode.
Definition BME280.h:51
@ STB_TIME_0_5
0.5 ms
Definition BME280.h:56

Temperature enabled in forced mode.

Definition at line 155 of file BME280.h.

◆ BME280_CONFIG_TEMP_SINGLE

const BME280::BME280Config Boardcore::BME280::BME280_CONFIG_TEMP_SINGLE
static
Initial value:
= {
@ SKIPPED
Skipped (output set to 0x8000)
Definition BME280.h:39
@ FILTER_OFF
Filter off.
Definition BME280.h:68
@ FORCED_MODE
Forced mode.
Definition BME280.h:50

Definition at line 158 of file BME280.h.

◆ BME280_DEFAULT_CONFIG

const BME280::BME280Config Boardcore::BME280::BME280_DEFAULT_CONFIG
static
Initial value:

Datasheet values for indoor navigation.

Definition at line 152 of file BME280.h.

◆ REG_ID_VAL

constexpr uint8_t Boardcore::BME280::REG_ID_VAL = 0x60
staticconstexpr

Who am I value.

Default register values

Definition at line 149 of file BME280.h.


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