RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::BMP280 Class Reference

BMP280 barometric temperature and pressure sensor (I2C), also deriving altitude from the measured pressure. More...

#include <BMP280.h>

Inheritance diagram for RumPi::BMP280:
[legend]
Collaboration diagram for RumPi::BMP280:
[legend]

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...
 

Detailed Description

BMP280 barometric temperature and pressure sensor (I2C), also deriving altitude from the measured pressure.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ BMP280()

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.

Author
Eddie O'Hagan
Date
8/13/2026
BMP280 barometer(0x76);
BMP280(const int bmpI2CAddress)
Builds a BMP280 bound to the given I2C address, computing its config/ctrl_meas bytes and opening the ...
Definition: BMP280.cpp:19
Parameters
[in]bmpI2CAddressThe sensor's I2C address.

◆ ~BMP280()

RumPi::BMP280::~BMP280 ( )
virtual

Destroys the sensor, turning it off first.

Author
Eddie O'Hagan
Date
8/13/2026
BMP280* barometer = new BMP280(0x76);
delete barometer;

Member Function Documentation

◆ GetAltitude()

double RumPi::BMP280::GetAltitude ( ) const

Gets the most recently calculated altitude, in meters.

Author
Eddie O'Hagan
Date
8/13/2026
double altitude = barometer.GetAltitude();
Returns
The altitude, in meters.

◆ GetChipID()

int RumPi::BMP280::GetChipID ( ) const

Gets the sensor's chip ID.

Author
Eddie O'Hagan
Date
8/13/2026
int id = barometer.GetChipID();
Returns
The chip ID.

◆ GetChipVersion()

int RumPi::BMP280::GetChipVersion ( ) const

Gets the sensor's chip version.

Author
Eddie O'Hagan
Date
8/13/2026
int version = barometer.GetChipVersion();
Returns
The chip version.

◆ GetConfigsByte()

int RumPi::BMP280::GetConfigsByte ( ) const

Gets the computed register config byte.

Author
Eddie O'Hagan
Date
8/13/2026
int config = barometer.GetConfigsByte();
Returns
The config byte.

◆ GetCtrlMeasByte()

int RumPi::BMP280::GetCtrlMeasByte ( ) const

Gets the computed register ctrl_meas byte.

Author
Eddie O'Hagan
Date
8/13/2026
int ctrlMeas = barometer.GetCtrlMeasByte();
Returns
The ctrl_meas byte.

◆ GetDigP1()

int RumPi::BMP280::GetDigP1 ( ) const

Gets the DigP1 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP1 = barometer.GetDigP1();
Returns
The DigP1 coefficient.

◆ GetDigP2()

int RumPi::BMP280::GetDigP2 ( ) const

Gets the DigP2 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP2 = barometer.GetDigP2();
Returns
The DigP2 coefficient.

◆ GetDigP3()

int RumPi::BMP280::GetDigP3 ( ) const

Gets the DigP3 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP3 = barometer.GetDigP3();
Returns
The DigP3 coefficient.

◆ GetDigP4()

int RumPi::BMP280::GetDigP4 ( ) const

Gets the DigP4 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP4 = barometer.GetDigP4();
Returns
The DigP4 coefficient.

◆ GetDigP5()

int RumPi::BMP280::GetDigP5 ( ) const

Gets the DigP5 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP5 = barometer.GetDigP5();
Returns
The DigP5 coefficient.

◆ GetDigP6()

int RumPi::BMP280::GetDigP6 ( ) const

Gets the DigP6 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP6 = barometer.GetDigP6();
Returns
The DigP6 coefficient.

◆ GetDigP7()

int RumPi::BMP280::GetDigP7 ( ) const

Gets the DigP7 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP7 = barometer.GetDigP7();
Returns
The DigP7 coefficient.

◆ GetDigP8()

int RumPi::BMP280::GetDigP8 ( ) const

Gets the DigP8 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP8 = barometer.GetDigP8();
Returns
The DigP8 coefficient.

◆ GetDigP9()

int RumPi::BMP280::GetDigP9 ( ) const

Gets the DigP9 pressure calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digP9 = barometer.GetDigP9();
Returns
The DigP9 coefficient.

◆ GetDigT1()

int RumPi::BMP280::GetDigT1 ( ) const

Gets the DigT1 temperature calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digT1 = barometer.GetDigT1();
Returns
The DigT1 coefficient.

◆ GetDigT2()

int RumPi::BMP280::GetDigT2 ( ) const

Gets the DigT2 temperature calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digT2 = barometer.GetDigT2();
Returns
The DigT2 coefficient.

◆ GetDigT3()

int RumPi::BMP280::GetDigT3 ( ) const

Gets the DigT3 temperature calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int digT3 = barometer.GetDigT3();
Returns
The DigT3 coefficient.

◆ GetFileDescriptor()

int RumPi::BMP280::GetFileDescriptor ( ) const

Gets the open i2c device file descriptor.

Author
Eddie O'Hagan
Date
8/13/2026
int fd = barometer.GetFileDescriptor();
Returns
The file descriptor.

◆ GetPressure()

double RumPi::BMP280::GetPressure ( ) const

Gets the most recently calculated pressure, in hPa.

Author
Eddie O'Hagan
Date
8/13/2026
double pressure = barometer.GetPressure();
Returns
The pressure, in hPa.

◆ GetTemperature()

double RumPi::BMP280::GetTemperature ( ) const

Gets the most recently calculated temperature, in Celsius.

Author
Eddie O'Hagan
Date
8/13/2026
double temperature = barometer.GetTemperature();
Returns
The temperature, in Celsius.

◆ ProcessRawValues()

void RumPi::BMP280::ProcessRawValues ( )
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).

Author
Eddie O'Hagan
Date
8/13/2026
barometer.ProcessRawValues();

Implements RumPi::BaseComponent.

◆ ReadByteDataFromRegister()

int RumPi::BMP280::ReadByteDataFromRegister ( const int  reg)
private

Reads a byte from a register over I2C.

Author
Eddie O'Hagan
Date
8/13/2026
int ReadByteDataFromRegister(const int reg)
Reads a byte from a register over I2C.
Definition: BMP280.cpp:190
constexpr int BMP280_REGISTER_TEMPDATA_MSB
Definition: BMP280.h:69
Parameters
[in]regThe register to read from.
Returns
The byte value read.

◆ ReadWordDataFromRegisterSigned()

int RumPi::BMP280::ReadWordDataFromRegisterSigned ( const int  reg)
private

Reads a signed 16-bit word from a register over I2C, applying two's-complement sign correction.

Author
Eddie O'Hagan
Date
8/13/2026
int ReadWordDataFromRegisterSigned(const int reg)
Reads a signed 16-bit word from a register over I2C, applying two's-complement sign correction.
Definition: BMP280.cpp:228
constexpr int BMP280_REGISTER_DIG_T2
Definition: BMP280.h:52
Parameters
[in]regThe register to read from.
Returns
The signed 16-bit value read.

◆ ReadWordDataFromRegisterUnsigned()

int RumPi::BMP280::ReadWordDataFromRegisterUnsigned ( const int  reg)
private

Reads an unsigned 16-bit word from a register over I2C.

Author
Eddie O'Hagan
Date
8/13/2026
int ReadWordDataFromRegisterUnsigned(const int reg)
Reads an unsigned 16-bit word from a register over I2C.
Definition: BMP280.cpp:209
constexpr int BMP280_REGISTER_DIG_T1
Definition: BMP280.h:51
Parameters
[in]regThe register to read from.
Returns
The unsigned 16-bit value read.

◆ SetAltitude()

void RumPi::BMP280::SetAltitude ( const double  alt)

Sets the cached altitude, in meters.

Author
Eddie O'Hagan
Date
8/13/2026
barometer.SetAltitude(120.0);
Parameters
[in]altThe altitude to set, in meters.

◆ SetPressure()

void RumPi::BMP280::SetPressure ( const double  pressure)

Sets the cached pressure, in hPa.

Author
Eddie O'Hagan
Date
8/13/2026
barometer.SetPressure(1013.25);
Parameters
[in]pressureThe pressure to set, in hPa.

◆ SetTemperature()

void RumPi::BMP280::SetTemperature ( const double  temp)

Sets the cached temperature, in Celsius.

Author
Eddie O'Hagan
Date
8/13/2026
barometer.SetTemperature(21.5);
Parameters
[in]tempThe temperature to set, in Celsius.

◆ ToString()

std::string RumPi::BMP280::ToString ( ) const
overridevirtual

Serializes the most recently calculated temperature, pressure, and altitude to a string.

Author
Eddie O'Hagan
Date
8/13/2026
std::string data = barometer.ToString();
Returns
A string describing the sensor's most recent readings.

Implements RumPi::BaseComponent.

◆ TurnOff()

void RumPi::BMP280::TurnOff ( )
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.

Author
Eddie O'Hagan
Date
8/13/2026
barometer.TurnOff();

Implements RumPi::BaseComponent.

◆ TurnOn()

void RumPi::BMP280::TurnOn ( )
overridevirtual

Reads the chip ID/version, soft-resets and configures the sensor, and reads its temperature/pressure calibration coefficients, reporting progress through the AlertManager.

Author
Eddie O'Hagan
Date
8/13/2026
barometer.TurnOn();

Implements RumPi::BaseComponent.

◆ WriteByteDataToRegister()

int RumPi::BMP280::WriteByteDataToRegister ( const int  reg,
const int  value 
)
private

Writes a byte to a register over I2C.

Author
Eddie O'Hagan
Date
8/13/2026
int WriteByteDataToRegister(const int reg, const int value)
Writes a byte to a register over I2C.
Definition: BMP280.cpp:171
int CTRL_MEAS
Register ctrl_meas byte; computed in the ctor.
Definition: BMP280.h:86
constexpr int BMP280_REGISTER_CONTROL
Definition: BMP280.h:66
Parameters
[in]regThe register to write to.
[in]valueThe byte value to write.
Returns
The wiringPi write result.

Member Data Documentation

◆ CONFIGS

int RumPi::BMP280::CONFIGS
private

Register config byte; computed in the ctor.

◆ CTRL_MEAS

int RumPi::BMP280::CTRL_MEAS
private

Register ctrl_meas byte; computed in the ctor.

◆ myAltitudeInM

double RumPi::BMP280::myAltitudeInM
private

The most recently calculated altitude, in meters.

◆ myChipID

int RumPi::BMP280::myChipID
private

The sensor's chip ID.

◆ myChipVersion

int RumPi::BMP280::myChipVersion
private

The sensor's chip version.

◆ myDigP1

int RumPi::BMP280::myDigP1
private

Pressure calibration coefficient.

◆ myDigP2

int RumPi::BMP280::myDigP2
private

Pressure calibration coefficient.

◆ myDigP3

int RumPi::BMP280::myDigP3
private

Pressure calibration coefficient.

◆ myDigP4

int RumPi::BMP280::myDigP4
private

Pressure calibration coefficient.

◆ myDigP5

int RumPi::BMP280::myDigP5
private

Pressure calibration coefficient.

◆ myDigP6

int RumPi::BMP280::myDigP6
private

Pressure calibration coefficient.

◆ myDigP7

int RumPi::BMP280::myDigP7
private

Pressure calibration coefficient.

◆ myDigP8

int RumPi::BMP280::myDigP8
private

Pressure calibration coefficient.

◆ myDigP9

int RumPi::BMP280::myDigP9
private

Pressure calibration coefficient.

◆ myDigT1

int RumPi::BMP280::myDigT1
private

Temperature calibration coefficient.

◆ myDigT2

int RumPi::BMP280::myDigT2
private

Temperature calibration coefficient.

◆ myDigT3

int RumPi::BMP280::myDigT3
private

Temperature calibration coefficient.

◆ myFileDescriptor

int RumPi::BMP280::myFileDescriptor
private

The open i2c device file descriptor.

◆ myPressureInHPA

double RumPi::BMP280::myPressureInHPA
private

The most recently calculated pressure, in hPa.

◆ myTemperatureInC

double RumPi::BMP280::myTemperatureInC
private

The most recently calculated temperature, in Celsius.


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