upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Member Functions | Protected Attributes

API for the GY65/BMP085 and BMP180 Atmospheric Pressure Sensors. More...

Detailed Description

Bosch GY65/BMP085 and BMP180 are high-precision, ultra-low power consumption pressure sensors. They operate in the range of 30,000-110,000 Pa.

This module has been tested on the GY65/BMP085 and BMP180 sensors.

bmp085.jpeg
// Instantiate a BMPX8X sensor on I2C using defaults.
upm::BMPX8X sensor;
// Print the pressure, altitude, sea level, and
// temperature values every 0.5 seconds
while (shouldRun) {
sensor.update();
cout << "Pressure: " << sensor.getPressure()
<< " Pa, Temperature: " << sensor.getTemperature()
<< " C, Altitude: " << sensor.getAltitude()
<< " m, Sea level: " << sensor.getSealevelPressure() << " Pa" << endl;
upm_delay_us(500000);
}
cout << "Exiting..." << endl;

Public Member Functions

 BMPX8X (int bus=BMPX8X_DEFAULT_I2C_BUS, int addr=BMPX8X_DEFAULT_I2C_ADDR)
 
virtual ~BMPX8X ()
 
void update ()
 
void reset ()
 
void init (BMPX8X_OSS_T oss=BMPX8X_OSS_ULTRAHIGHRES)
 
void setOversampling (BMPX8X_OSS_T oss=BMPX8X_OSS_ULTRAHIGHRES)
 
int getPressure ()
 
float getTemperature ()
 
int getSealevelPressure (float meters)
 
int getSealevelPressure ()
 
float getAltitude (int sealevelPressure=101325)
 
int getTemperatureCelsius ()
 
int getPressurePa ()
 
const char * getModuleName ()
 

Protected Member Functions

uint8_t readReg (uint8_t reg)
 
int readRegs (uint8_t reg, uint8_t *buffer, int len)
 
void writeReg (uint8_t reg, uint8_t val)
 

Protected Attributes

bmpx8x_context m_bmpx8x
 

Constructor & Destructor Documentation

BMPX8X ( int  bus = BMPX8X_DEFAULT_I2C_BUS,
int  addr = BMPX8X_DEFAULT_I2C_ADDR 
)

Instantiates a BMPX8X object

Parameters
busI2C bus to use.
addrThe I2C address of the device.
Exceptions
std::runtime_erroron failure.

Here is the caller graph for this function:

~BMPX8X ( )
virtual

BMPX8X object destructor.

Here is the call graph for this function:

Member Function Documentation

void update ( void  )

Query the device and update the internal state. This method must be called before calling getPressure(), getTemperature(), getSealevelPressure(), and getAltitude() to retrieve values.

Exceptions
std::runtime_erroron failure.

Here is the call graph for this function:

Here is the caller graph for this function:

void reset ( )

Reset the device to power-on defaults. All calibration data is lost when the device is reset, so you should call init() before attempting to use the device.

Exceptions
std::runtime_erroron failure.

Here is the call graph for this function:

void init ( BMPX8X_OSS_T  oss = BMPX8X_OSS_ULTRAHIGHRES)

Initialize the device, read calibration data, and start operation. This function is called from the constructor, so it will not typically need to be called by a user unless the device is reset.

Parameters
ossOne of the BMPX8X_OSS_T values. The default is BMPX8X_OSS_ULTRAHIGHRES.
Exceptions
std::runtime_erroron failure.

Here is the call graph for this function:

void setOversampling ( BMPX8X_OSS_T  oss = BMPX8X_OSS_ULTRAHIGHRES)

Set the oversampling (precision mode) of the device. Higher precision requires more time to complete. This call takes effect the next time update() is called.

Parameters
ossOne of the BMPX8X_OSS_T values. The default is BMPX8X_OSS_ULTRAHIGHRES.

Here is the call graph for this function:

int getPressure ( )

Returns the calculated pressure in Pascals. update() must have been called prior to calling this function.

Returns
The pressure in Pascals.

Here is the call graph for this function:

Here is the caller graph for this function:

float getTemperature ( void  )

Returns the calculated temperature in Celsius. update() must have been called prior to calling this function.

Returns
The temperature in Celsius.

Here is the call graph for this function:

Here is the caller graph for this function:

int getSealevelPressure ( float  meters)

Using the supplied altitude in meters, compute the pressure at sea level in Pascals. update() must have been called prior to calling this function.

Parameters
metersThe altitude in meters.
Returns
The computed sea level pressure in Pascals.

Here is the call graph for this function:

int getSealevelPressure ( )
inline

Using the current calculated altitude, compute the pressure at sea level in Pascals. update() must have been called prior to calling this function.

Returns
The computed sea level pressure in Pascals.

Here is the call graph for this function:

float getAltitude ( int  sealevelPressure = 101325)

Calculate the current altitude in meters, given a sea level pressure in Pascals. The default sea level pressure is 101325 Pascals. update() must have been called prior to calling this function.

Parameters
sealevelPressureThe pressure at sea level in Pascals. The default is 101325 Pascals.
Returns
the computed altitude in meters.

Here is the call graph for this function:

Here is the caller graph for this function:

int getTemperatureCelsius ( )
inlinevirtual

Return latest calculated temperature value in Celsius. See ITemperatureSensor.

Returns
The current temperature in Celsius.

Implements ITemperatureSensor.

Here is the call graph for this function:

int getPressurePa ( )
inlinevirtual

Return latest calculated pressure value in Pascals. See IPressureSensor.

Returns
The current pressure in Pascals.

Implements IPressureSensor.

Here is the call graph for this function:

const char* getModuleName ( )
inlinevirtual

Returns the name of module.

Returns
The name of the module.

Implements IModuleStatus.

Here is the call graph for this function:

uint8_t readReg ( uint8_t  reg)
protected

Read a register.

Parameters
regThe register to read.
Returns
The value of the register.

Here is the call graph for this function:

Here is the caller graph for this function:

int readRegs ( uint8_t  reg,
uint8_t *  buffer,
int  len 
)
protected

Read contiguous registers into a buffer.

Parameters
bufferThe buffer to store the results.
lenThe number of registers to read.
Returns
The number of bytes read.
Exceptions
std::runtime_erroron failure.

Here is the call graph for this function:

Here is the caller graph for this function:

void writeReg ( uint8_t  reg,
uint8_t  val 
)
protected

Write to a register.

Parameters
regThe register to write to.
valThe value to write.
Exceptions
std::runtime_erroron failure.

Here is the call graph for this function:

Here is the caller graph for this function:

Inheritance diagram for BMPX8X:
Inheritance graph
[legend]
Collaboration diagram for BMPX8X:
Collaboration graph
[legend]

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