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

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

#include <BMP180.h>

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

Public Member Functions

 BMP180 (int bmpI2CAddress, const char *i2cDeviceFilePath)
 Builds a BMP180 bound to the given I2C address, copying the provided i2c device file path. More...
 
virtual ~BMP180 ()
 Destroys the sensor, turning it off and freeing the copied device file path. More...
 
virtual void TurnOn () override
 Opens the i2c device, binds the slave address, and reads the sensor's EPROM calibration coefficients, reporting progress and any failures through the AlertManager. More...
 
virtual void TurnOff () override
 Closes the i2c device and frees the copied device file path, reporting any close failure through the AlertManager. More...
 
virtual std::string ToString () const override
 Serializes the most recently calculated temperature, pressure, and altitude to a string. More...
 
virtual void ProcessRawValues () override
 Recomputes and caches the temperature, pressure, and altitude from fresh sensor reads. More...
 
float CalculateTemperature ()
 Calculates the compensated temperature (in Celsius) from a raw read using the sensor's calibration coefficients. More...
 
long CalculatePressure ()
 Calculates the compensated pressure (in pascal) from raw reads using the sensor's calibration coefficients. More...
 
float CalculateAltitude ()
 Approximates the altitude (in meters) from the measured pressure relative to average sea-level pressure. More...
 
int GetFileDescriptor () const
 Gets the open i2c device file descriptor. More...
 
int GetI2CAddress () const
 Gets the sensor's I2C address. More...
 
int GetOversamplingMode () const
 Gets the sensor's oversampling mode. More...
 
char * GetI2CDeviceFilePath () const
 Gets the i2c device file path. More...
 
int32_t GetAC1 () const
 Gets the AC1 calibration coefficient. More...
 
int32_t GetAC2 () const
 Gets the AC2 calibration coefficient. More...
 
int32_t GetAC3 () const
 Gets the AC3 calibration coefficient. More...
 
int32_t GetAC4 () const
 Gets the AC4 calibration coefficient. More...
 
int32_t GetAC5 () const
 Gets the AC5 calibration coefficient. More...
 
int32_t GetAC6 () const
 Gets the AC6 calibration coefficient. More...
 
int32_t GetB1 () const
 Gets the B1 calibration coefficient. More...
 
int32_t GetB2 () const
 Gets the B2 calibration coefficient. More...
 
int32_t GetMB () const
 Gets the MB calibration coefficient. More...
 
int32_t GetMC () const
 Gets the MC calibration coefficient. More...
 
int32_t GetMD () const
 Gets the MD calibration coefficient. 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

void ReadSingleEpromFromRegister (int32_t *store, uint8_t reg, int32_t sign)
 Reads a single calibration coefficient from the BMP180 EPROM, byte-swapping it from the chip's ordering and applying two's-complement sign correction when the coefficient is signed. More...
 
void ReadEprom ()
 Reads all eleven calibration coefficients from the BMP180 EPROM into their member variables. More...
 
int32_t ReadRawTemperature ()
 Reads the raw (uncompensated) temperature value from the sensor, byte-swapped to host ordering. More...
 
int32_t ReadRawPressure (uint8_t oversamplingMode)
 Reads the raw (uncompensated) pressure value from the sensor at the given oversampling mode. More...
 

Private Attributes

int myFileDescriptor
 File descriptor. More...
 
int myI2CAddress
 I2C device address. More...
 
int myOversamplingMode
 BMP180 oversampling mode. More...
 
char * myI2CDeviceFilePath
 i2c device file path. More...
 
int32_t myAC1
 EPROM calibration coefficients. More...
 
int32_t myAC2
 
int32_t myAC3
 
int32_t myAC4
 
int32_t myAC5
 
int32_t myAC6
 
int32_t myB1
 
int32_t myB2
 
int32_t myMB
 
int32_t myMC
 
int32_t myMD
 
float myRecentlyCalculatedTemperatureInC
 Most recently calculated values. More...
 
long myRecentlyCalculatedPressureInHPA
 
float myRecentlyCalculatedAltitudeInM
 

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

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

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ BMP180()

RumPi::BMP180::BMP180 ( int  bmpI2CAddress,
const char *  i2cDeviceFilePath 
)

Builds a BMP180 bound to the given I2C address, copying the provided i2c device file path.

Author
Eddie O'Hagan
Date
8/13/2026
BMP180 barometer(0x77, "/dev/i2c-1");
BMP180(int bmpI2CAddress, const char *i2cDeviceFilePath)
Builds a BMP180 bound to the given I2C address, copying the provided i2c device file path.
Definition: BMP180.cpp:19
Parameters
[in]bmpI2CAddressThe sensor's I2C address.
[in]i2cDeviceFilePathThe i2c device file path (copied internally; may be nullptr).

◆ ~BMP180()

RumPi::BMP180::~BMP180 ( )
virtual

Destroys the sensor, turning it off and freeing the copied device file path.

Author
Eddie O'Hagan
Date
8/13/2026
BMP180* barometer = new BMP180(0x77, "/dev/i2c-1");
delete barometer;

Member Function Documentation

◆ CalculateAltitude()

float RumPi::BMP180::CalculateAltitude ( )

Approximates the altitude (in meters) from the measured pressure relative to average sea-level pressure.

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

◆ CalculatePressure()

long RumPi::BMP180::CalculatePressure ( )

Calculates the compensated pressure (in pascal) from raw reads using the sensor's calibration coefficients.

Author
Eddie O'Hagan
Date
8/13/2026
long pressure = barometer.CalculatePressure();
Returns
The measured pressure, in pascal.

◆ CalculateTemperature()

float RumPi::BMP180::CalculateTemperature ( )

Calculates the compensated temperature (in Celsius) from a raw read using the sensor's calibration coefficients.

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

◆ GetAC1()

int32_t RumPi::BMP180::GetAC1 ( ) const

Gets the AC1 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t ac1 = barometer.GetAC1();
Returns
The AC1 coefficient.

◆ GetAC2()

int32_t RumPi::BMP180::GetAC2 ( ) const

Gets the AC2 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t ac2 = barometer.GetAC2();
Returns
The AC2 coefficient.

◆ GetAC3()

int32_t RumPi::BMP180::GetAC3 ( ) const

Gets the AC3 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t ac3 = barometer.GetAC3();
Returns
The AC3 coefficient.

◆ GetAC4()

int32_t RumPi::BMP180::GetAC4 ( ) const

Gets the AC4 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t ac4 = barometer.GetAC4();
Returns
The AC4 coefficient.

◆ GetAC5()

int32_t RumPi::BMP180::GetAC5 ( ) const

Gets the AC5 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t ac5 = barometer.GetAC5();
Returns
The AC5 coefficient.

◆ GetAC6()

int32_t RumPi::BMP180::GetAC6 ( ) const

Gets the AC6 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t ac6 = barometer.GetAC6();
Returns
The AC6 coefficient.

◆ GetB1()

int32_t RumPi::BMP180::GetB1 ( ) const

Gets the B1 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t b1 = barometer.GetB1();
Returns
The B1 coefficient.

◆ GetB2()

int32_t RumPi::BMP180::GetB2 ( ) const

Gets the B2 calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t b2 = barometer.GetB2();
Returns
The B2 coefficient.

◆ GetFileDescriptor()

int RumPi::BMP180::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.

◆ GetI2CAddress()

int RumPi::BMP180::GetI2CAddress ( ) const

Gets the sensor's I2C address.

Author
Eddie O'Hagan
Date
8/13/2026
int address = barometer.GetI2CAddress();
Returns
The I2C address.

◆ GetI2CDeviceFilePath()

char * RumPi::BMP180::GetI2CDeviceFilePath ( ) const

Gets the i2c device file path.

Author
Eddie O'Hagan
Date
8/13/2026
char* path = barometer.GetI2CDeviceFilePath();
Returns
The i2c device file path.

◆ GetMB()

int32_t RumPi::BMP180::GetMB ( ) const

Gets the MB calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t mb = barometer.GetMB();
Returns
The MB coefficient.

◆ GetMC()

int32_t RumPi::BMP180::GetMC ( ) const

Gets the MC calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t mc = barometer.GetMC();
Returns
The MC coefficient.

◆ GetMD()

int32_t RumPi::BMP180::GetMD ( ) const

Gets the MD calibration coefficient.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t md = barometer.GetMD();
Returns
The MD coefficient.

◆ GetOversamplingMode()

int RumPi::BMP180::GetOversamplingMode ( ) const

Gets the sensor's oversampling mode.

Author
Eddie O'Hagan
Date
8/13/2026
int mode = barometer.GetOversamplingMode();
Returns
The oversampling mode.

◆ ProcessRawValues()

void RumPi::BMP180::ProcessRawValues ( )
overridevirtual

Recomputes and caches the temperature, pressure, and altitude from fresh sensor reads.

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

Implements RumPi::BaseComponent.

◆ ReadEprom()

void RumPi::BMP180::ReadEprom ( )
private

Reads all eleven calibration coefficients from the BMP180 EPROM into their member variables.

Author
Eddie O'Hagan
Date
8/13/2026
void ReadEprom()
Reads all eleven calibration coefficients from the BMP180 EPROM into their member variables.
Definition: BMP180.cpp:265

◆ ReadRawPressure()

int32_t RumPi::BMP180::ReadRawPressure ( uint8_t  oversamplingMode)
private

Reads the raw (uncompensated) pressure value from the sensor at the given oversampling mode.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t rawPressure = ReadRawPressure(BMP180_PRE_OSS0);
int32_t ReadRawPressure(uint8_t oversamplingMode)
Reads the raw (uncompensated) pressure value from the sensor at the given oversampling mode.
Definition: BMP180.cpp:335
constexpr int BMP180_PRE_OSS0
Definition: BMP180.h:25
Parameters
[in]oversamplingModeThe oversampling mode (BMP180_PRE_OSS0 through BMP180_PRE_OSS3).
Returns
The raw pressure reading.

◆ ReadRawTemperature()

int32_t RumPi::BMP180::ReadRawTemperature ( )
private

Reads the raw (uncompensated) temperature value from the sensor, byte-swapped to host ordering.

Author
Eddie O'Hagan
Date
8/13/2026
int32_t rawTemperature = ReadRawTemperature();
int32_t ReadRawTemperature()
Reads the raw (uncompensated) temperature value from the sensor, byte-swapped to host ordering.
Definition: BMP180.cpp:309
Returns
The raw temperature reading.

◆ ReadSingleEpromFromRegister()

void RumPi::BMP180::ReadSingleEpromFromRegister ( int32_t *  store,
uint8_t  reg,
int32_t  sign 
)
private

Reads a single calibration coefficient from the BMP180 EPROM, byte-swapping it from the chip's ordering and applying two's-complement sign correction when the coefficient is signed.

Author
Eddie O'Hagan
Date
8/13/2026
void ReadSingleEpromFromRegister(int32_t *store, uint8_t reg, int32_t sign)
Reads a single calibration coefficient from the BMP180 EPROM, byte-swapping it from the chip's orderi...
Definition: BMP180.cpp:238
int32_t myAC1
EPROM calibration coefficients.
Definition: BMP180.h:121
constexpr int BMP180_REG_AC1_H
Definition: BMP180.h:43
Parameters
[out]storeThe coefficient to write.
[in]regThe register address to read from.
[in]signNon-zero if the coefficient is signed.

◆ ToString()

std::string RumPi::BMP180::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::BMP180::TurnOff ( )
overridevirtual

Closes the i2c device and frees the copied device file path, reporting any close failure through the AlertManager.

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

Implements RumPi::BaseComponent.

◆ TurnOn()

void RumPi::BMP180::TurnOn ( )
overridevirtual

Opens the i2c device, binds the slave address, and reads the sensor's EPROM calibration coefficients, reporting progress and any failures through the AlertManager.

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

Implements RumPi::BaseComponent.

Member Data Documentation

◆ myAC1

int32_t RumPi::BMP180::myAC1
private

EPROM calibration coefficients.

◆ myAC2

int32_t RumPi::BMP180::myAC2
private

◆ myAC3

int32_t RumPi::BMP180::myAC3
private

◆ myAC4

int32_t RumPi::BMP180::myAC4
private

◆ myAC5

int32_t RumPi::BMP180::myAC5
private

◆ myAC6

int32_t RumPi::BMP180::myAC6
private

◆ myB1

int32_t RumPi::BMP180::myB1
private

◆ myB2

int32_t RumPi::BMP180::myB2
private

◆ myFileDescriptor

int RumPi::BMP180::myFileDescriptor
private

File descriptor.

◆ myI2CAddress

int RumPi::BMP180::myI2CAddress
private

I2C device address.

◆ myI2CDeviceFilePath

char* RumPi::BMP180::myI2CDeviceFilePath
private

i2c device file path.

◆ myMB

int32_t RumPi::BMP180::myMB
private

◆ myMC

int32_t RumPi::BMP180::myMC
private

◆ myMD

int32_t RumPi::BMP180::myMD
private

◆ myOversamplingMode

int RumPi::BMP180::myOversamplingMode
private

BMP180 oversampling mode.

◆ myRecentlyCalculatedAltitudeInM

float RumPi::BMP180::myRecentlyCalculatedAltitudeInM
private

◆ myRecentlyCalculatedPressureInHPA

long RumPi::BMP180::myRecentlyCalculatedPressureInHPA
private

◆ myRecentlyCalculatedTemperatureInC

float RumPi::BMP180::myRecentlyCalculatedTemperatureInC
private

Most recently calculated values.


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