![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
BMP280 barometric temperature and pressure sensor (I2C), also deriving altitude from the measured pressure. More...
#include <BMP280.h>
Public Member Functions | |
| BMP280 (const int bmpI2CAddress) | |
| Builds a BMP280 bound to the given I2C address, computing its config/ctrl_meas bytes and opening the i2c device. More... | |
| virtual | ~BMP280 () |
| Destroys the sensor, turning it off first. More... | |
| virtual void | TurnOn () override |
| Reads the chip ID/version, soft-resets and configures the sensor, and reads its temperature/pressure calibration coefficients, reporting progress through the AlertManager. More... | |
| virtual void | TurnOff () override |
| No-op: the BMP280's only OS resource (the i2c file descriptor) is opened in the constructor and closed in the destructor, so a power-off releases nothing. More... | |
| virtual std::string | ToString () const override |
| Serializes the most recently calculated temperature, pressure, and altitude to a string. More... | |
| virtual void | ProcessRawValues () override |
| Reads the raw temperature and pressure registers and applies the Bosch datasheet compensation formulas to update the cached temperature (C), pressure (hPa), and approximated altitude (m). More... | |
| int | GetConfigsByte () const |
| Gets the computed register config byte. More... | |
| int | GetCtrlMeasByte () const |
| Gets the computed register ctrl_meas byte. More... | |
| int | GetFileDescriptor () const |
| Gets the open i2c device file descriptor. More... | |
| int | GetChipID () const |
| Gets the sensor's chip ID. More... | |
| int | GetChipVersion () const |
| Gets the sensor's chip version. More... | |
| double | GetTemperature () const |
| Gets the most recently calculated temperature, in Celsius. More... | |
| double | GetPressure () const |
| Gets the most recently calculated pressure, in hPa. More... | |
| double | GetAltitude () const |
| Gets the most recently calculated altitude, in meters. More... | |
| int | GetDigT1 () const |
| Gets the DigT1 temperature calibration coefficient. More... | |
| int | GetDigT2 () const |
| Gets the DigT2 temperature calibration coefficient. More... | |
| int | GetDigT3 () const |
| Gets the DigT3 temperature calibration coefficient. More... | |
| int | GetDigP1 () const |
| Gets the DigP1 pressure calibration coefficient. More... | |
| int | GetDigP2 () const |
| Gets the DigP2 pressure calibration coefficient. More... | |
| int | GetDigP3 () const |
| Gets the DigP3 pressure calibration coefficient. More... | |
| int | GetDigP4 () const |
| Gets the DigP4 pressure calibration coefficient. More... | |
| int | GetDigP5 () const |
| Gets the DigP5 pressure calibration coefficient. More... | |
| int | GetDigP6 () const |
| Gets the DigP6 pressure calibration coefficient. More... | |
| int | GetDigP7 () const |
| Gets the DigP7 pressure calibration coefficient. More... | |
| int | GetDigP8 () const |
| Gets the DigP8 pressure calibration coefficient. More... | |
| int | GetDigP9 () const |
| Gets the DigP9 pressure calibration coefficient. More... | |
| void | SetTemperature (const double temp) |
| Sets the cached temperature, in Celsius. More... | |
| void | SetPressure (const double pressure) |
| Sets the cached pressure, in hPa. More... | |
| void | SetAltitude (const double alt) |
| Sets the cached altitude, in meters. More... | |
Public Member Functions inherited from RumPi::BaseComponent | |
| BaseComponent () | |
| Builds a base component with an unknown type and an empty name. More... | |
| virtual | ~BaseComponent () |
| Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More... | |
| virtual void | TurnOn ()=0 |
| Turns the component on (e.g. More... | |
| virtual void | TurnOff ()=0 |
| Turns the component off. More... | |
| virtual std::string | ToString () const =0 |
| Serializes the component's current readings to a string (usually JSON). More... | |
| virtual void | ProcessRawValues ()=0 |
| Reads and processes the component's latest raw values (called once per poll). More... | |
| virtual EComponentType | GetComponentType () const |
| Gets the component's type. More... | |
| const std::string & | GetName () const |
| Gets the component's unique per-instance name. More... | |
| void | SetName (const std::string &name) |
| Sets the component's unique per-instance name. More... | |
Private Member Functions | |
| int | WriteByteDataToRegister (const int reg, const int value) |
| Writes a byte to a register over I2C. More... | |
| int | ReadByteDataFromRegister (const int reg) |
| Reads a byte from a register over I2C. More... | |
| int | ReadWordDataFromRegisterUnsigned (const int reg) |
| Reads an unsigned 16-bit word from a register over I2C. More... | |
| int | ReadWordDataFromRegisterSigned (const int reg) |
| Reads a signed 16-bit word from a register over I2C, applying two's-complement sign correction. More... | |
Private Attributes | |
| int | CONFIGS |
| Register config byte; computed in the ctor. More... | |
| int | CTRL_MEAS |
| Register ctrl_meas byte; computed in the ctor. More... | |
| int | myFileDescriptor |
| The open i2c device file descriptor. More... | |
| int | myChipID |
| The sensor's chip ID. More... | |
| int | myChipVersion |
| The sensor's chip version. More... | |
| double | myTemperatureInC |
| The most recently calculated temperature, in Celsius. More... | |
| double | myPressureInHPA |
| The most recently calculated pressure, in hPa. More... | |
| double | myAltitudeInM |
| The most recently calculated altitude, in meters. More... | |
| int | myDigT1 |
| Temperature calibration coefficient. More... | |
| int | myDigT2 |
| Temperature calibration coefficient. More... | |
| int | myDigT3 |
| Temperature calibration coefficient. More... | |
| int | myDigP1 |
| Pressure calibration coefficient. More... | |
| int | myDigP2 |
| Pressure calibration coefficient. More... | |
| int | myDigP3 |
| Pressure calibration coefficient. More... | |
| int | myDigP4 |
| Pressure calibration coefficient. More... | |
| int | myDigP5 |
| Pressure calibration coefficient. More... | |
| int | myDigP6 |
| Pressure calibration coefficient. More... | |
| int | myDigP7 |
| Pressure calibration coefficient. More... | |
| int | myDigP8 |
| Pressure calibration coefficient. More... | |
| int | myDigP9 |
| Pressure calibration coefficient. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from RumPi::BaseComponent | |
| static std::string | ComponentTypeToString (const EComponentType theComponentTypeToConvert) |
| Maps an EComponentType to its string name. More... | |
| static EComponentType | StringToComponentType (const std::string &theComponentTypeName) |
| Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More... | |
Protected Attributes inherited from RumPi::BaseComponent | |
| EComponentType | myComponentType |
| The kind of component this is (set by each concrete subclass). More... | |
| std::string | myName |
| A unique per-instance name, assigned when the component is added to the manager. More... | |
BMP280 barometric temperature and pressure sensor (I2C), also deriving altitude from the measured pressure.
| RumPi::BMP280::BMP280 | ( | const int | bmpI2CAddress | ) |
Builds a BMP280 bound to the given I2C address, computing its config/ctrl_meas bytes and opening the i2c device.
| [in] | bmpI2CAddress | The sensor's I2C address. |
|
virtual |
| double RumPi::BMP280::GetAltitude | ( | ) | const |
Gets the most recently calculated altitude, in meters.
| int RumPi::BMP280::GetChipID | ( | ) | const |
Gets the sensor's chip ID.
| int RumPi::BMP280::GetChipVersion | ( | ) | const |
Gets the sensor's chip version.
| int RumPi::BMP280::GetConfigsByte | ( | ) | const |
Gets the computed register config byte.
| int RumPi::BMP280::GetCtrlMeasByte | ( | ) | const |
Gets the computed register ctrl_meas byte.
| int RumPi::BMP280::GetDigP1 | ( | ) | const |
Gets the DigP1 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP2 | ( | ) | const |
Gets the DigP2 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP3 | ( | ) | const |
Gets the DigP3 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP4 | ( | ) | const |
Gets the DigP4 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP5 | ( | ) | const |
Gets the DigP5 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP6 | ( | ) | const |
Gets the DigP6 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP7 | ( | ) | const |
Gets the DigP7 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP8 | ( | ) | const |
Gets the DigP8 pressure calibration coefficient.
| int RumPi::BMP280::GetDigP9 | ( | ) | const |
Gets the DigP9 pressure calibration coefficient.
| int RumPi::BMP280::GetDigT1 | ( | ) | const |
Gets the DigT1 temperature calibration coefficient.
| int RumPi::BMP280::GetDigT2 | ( | ) | const |
Gets the DigT2 temperature calibration coefficient.
| int RumPi::BMP280::GetDigT3 | ( | ) | const |
Gets the DigT3 temperature calibration coefficient.
| int RumPi::BMP280::GetFileDescriptor | ( | ) | const |
Gets the open i2c device file descriptor.
| double RumPi::BMP280::GetPressure | ( | ) | const |
Gets the most recently calculated pressure, in hPa.
| double RumPi::BMP280::GetTemperature | ( | ) | const |
Gets the most recently calculated temperature, in Celsius.
|
overridevirtual |
Reads the raw temperature and pressure registers and applies the Bosch datasheet compensation formulas to update the cached temperature (C), pressure (hPa), and approximated altitude (m).
Implements RumPi::BaseComponent.
|
private |
Reads a byte from a register over I2C.
| [in] | reg | The register to read from. |
|
private |
Reads a signed 16-bit word from a register over I2C, applying two's-complement sign correction.
| [in] | reg | The register to read from. |
|
private |
Reads an unsigned 16-bit word from a register over I2C.
| [in] | reg | The register to read from. |
| void RumPi::BMP280::SetAltitude | ( | const double | alt | ) |
Sets the cached altitude, in meters.
| [in] | alt | The altitude to set, in meters. |
| void RumPi::BMP280::SetPressure | ( | const double | pressure | ) |
Sets the cached pressure, in hPa.
| [in] | pressure | The pressure to set, in hPa. |
| void RumPi::BMP280::SetTemperature | ( | const double | temp | ) |
Sets the cached temperature, in Celsius.
| [in] | temp | The temperature to set, in Celsius. |
|
overridevirtual |
Serializes the most recently calculated temperature, pressure, and altitude to a string.
Implements RumPi::BaseComponent.
|
overridevirtual |
No-op: the BMP280's only OS resource (the i2c file descriptor) is opened in the constructor and closed in the destructor, so a power-off releases nothing.
Implements RumPi::BaseComponent.
|
overridevirtual |
Reads the chip ID/version, soft-resets and configures the sensor, and reads its temperature/pressure calibration coefficients, reporting progress through the AlertManager.
Implements RumPi::BaseComponent.
|
private |
Writes a byte to a register over I2C.
| [in] | reg | The register to write to. |
| [in] | value | The byte value to write. |
|
private |
Register config byte; computed in the ctor.
|
private |
Register ctrl_meas byte; computed in the ctor.
|
private |
The most recently calculated altitude, in meters.
|
private |
The sensor's chip ID.
|
private |
The sensor's chip version.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Pressure calibration coefficient.
|
private |
Temperature calibration coefficient.
|
private |
Temperature calibration coefficient.
|
private |
Temperature calibration coefficient.
|
private |
The open i2c device file descriptor.
|
private |
The most recently calculated pressure, in hPa.
|
private |
The most recently calculated temperature, in Celsius.