![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
BMP180 barometric temperature and pressure sensor (I2C), also deriving altitude from the measured pressure. More...
#include <BMP180.h>
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... | |
BMP180 barometric temperature and pressure sensor (I2C), also deriving altitude from the measured pressure.
| RumPi::BMP180::BMP180 | ( | int | bmpI2CAddress, |
| const char * | i2cDeviceFilePath | ||
| ) |
Builds a BMP180 bound to the given I2C address, copying the provided i2c device file path.
| [in] | bmpI2CAddress | The sensor's I2C address. |
| [in] | i2cDeviceFilePath | The i2c device file path (copied internally; may be nullptr). |
|
virtual |
| float RumPi::BMP180::CalculateAltitude | ( | ) |
Approximates the altitude (in meters) from the measured pressure relative to average sea-level pressure.
| long RumPi::BMP180::CalculatePressure | ( | ) |
Calculates the compensated pressure (in pascal) from raw reads using the sensor's calibration coefficients.
| float RumPi::BMP180::CalculateTemperature | ( | ) |
Calculates the compensated temperature (in Celsius) from a raw read using the sensor's calibration coefficients.
| int32_t RumPi::BMP180::GetAC1 | ( | ) | const |
Gets the AC1 calibration coefficient.
| int32_t RumPi::BMP180::GetAC2 | ( | ) | const |
Gets the AC2 calibration coefficient.
| int32_t RumPi::BMP180::GetAC3 | ( | ) | const |
Gets the AC3 calibration coefficient.
| int32_t RumPi::BMP180::GetAC4 | ( | ) | const |
Gets the AC4 calibration coefficient.
| int32_t RumPi::BMP180::GetAC5 | ( | ) | const |
Gets the AC5 calibration coefficient.
| int32_t RumPi::BMP180::GetAC6 | ( | ) | const |
Gets the AC6 calibration coefficient.
| int32_t RumPi::BMP180::GetB1 | ( | ) | const |
Gets the B1 calibration coefficient.
| int32_t RumPi::BMP180::GetB2 | ( | ) | const |
Gets the B2 calibration coefficient.
| int RumPi::BMP180::GetFileDescriptor | ( | ) | const |
Gets the open i2c device file descriptor.
| int RumPi::BMP180::GetI2CAddress | ( | ) | const |
Gets the sensor's I2C address.
| char * RumPi::BMP180::GetI2CDeviceFilePath | ( | ) | const |
Gets the i2c device file path.
| int32_t RumPi::BMP180::GetMB | ( | ) | const |
Gets the MB calibration coefficient.
| int32_t RumPi::BMP180::GetMC | ( | ) | const |
Gets the MC calibration coefficient.
| int32_t RumPi::BMP180::GetMD | ( | ) | const |
Gets the MD calibration coefficient.
| int RumPi::BMP180::GetOversamplingMode | ( | ) | const |
Gets the sensor's oversampling mode.
|
overridevirtual |
Recomputes and caches the temperature, pressure, and altitude from fresh sensor reads.
Implements RumPi::BaseComponent.
|
private |
|
private |
Reads the raw (uncompensated) pressure value from the sensor at the given oversampling mode.
| [in] | oversamplingMode | The oversampling mode (BMP180_PRE_OSS0 through BMP180_PRE_OSS3). |
|
private |
Reads the raw (uncompensated) temperature value from the sensor, byte-swapped to host ordering.
|
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.
| [out] | store | The coefficient to write. |
| [in] | reg | The register address to read from. |
| [in] | sign | Non-zero if the coefficient is signed. |
|
overridevirtual |
Serializes the most recently calculated temperature, pressure, and altitude to a string.
Implements RumPi::BaseComponent.
|
overridevirtual |
Closes the i2c device and frees the copied device file path, reporting any close failure through the AlertManager.
Implements RumPi::BaseComponent.
|
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.
Implements RumPi::BaseComponent.
|
private |
EPROM calibration coefficients.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
File descriptor.
|
private |
I2C device address.
|
private |
i2c device file path.
|
private |
|
private |
|
private |
|
private |
BMP180 oversampling mode.
|
private |
|
private |
|
private |
Most recently calculated values.