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

UPM API for the MS5803 Pressure and Temperature sensor. More...

Detailed Description

The MS5803-14BA is a new generation of high resolution pressure sensors with SPI and I2C bus interface. It is optimized for depth measurement systems with a water depth resolution of 1cm and below. The sensor module includes a high linear pressure sensor and an ultra low power 24 bit delta-sigma ADC with internal factory calibrated coefficients. It provides a precise digital 24 bit pressure and temperature value and different operation modes that allow the user to optimize for conversion speed and current consumption. A high resolution temperature output allows the implementation of a depth measurement systems and thermometer function without any additional sensor.

The device is driven at 3.3vdc, and has a pressure range of between 0 and 14 Bar, and a temperature range of between -40 and +85C.

// Instantiate a MS5803 instance using i2c bus 0 and default address
upm::MS5803 sensor(0);
// For SPI, bus 0, you would pass -1 as the address, and a valid
// pin for CS (or -1 if you are using a hw pin you have no control
// over, like edison):
// MS5803(0, -1, 9);
while (shouldRun) {
// update our values from the sensor
sensor.update();
cout << "Temperature: " << sensor.getTemperature() << " C, "
<< "Pressure: " << sensor.getPressure() << " mbar" << endl;
upm_delay(1);
}

Public Member Functions

 MS5803 (int bus, int address=MS5803_DEFAULT_I2C_ADDR, int csPin=-1)
 
 ~MS5803 ()
 
void reset ()
 
void update ()
 
void setTemperatureOSR (MS5803_OSR_T osr)
 
void setPressureOSR (MS5803_OSR_T osr)
 
float getTemperature ()
 
float getPressure ()
 

Protected Member Functions

void loadCoefficients ()
 
std::string busRead (int cmd, int len)
 
void busWrite (int cmd, std::string data)
 

Protected Attributes

ms5803_context m_ms5803
 

Constructor & Destructor Documentation

MS5803 ( int  bus,
int  address = MS5803_DEFAULT_I2C_ADDR,
int  csPin = -1 
)

MS5803 constructor. The default arguments inititialize I2C operation and the default I2C address.

Parameters
busi2c/spi bus to use
addressThe address for this device if using I2C. If using SPI, supply -1 for this parameter.
csPinThe GPIO pin to use for Chip Select (CS). This is only needed for SPI, and only if your SPI implementation requires it. Otherwise, just pass -1 if not using SPI, or your CS is handled automatically by your SPI implementation.
~MS5803 ( )

MS5803 Destructor

Member Function Documentation

void reset ( )

Reset the device.

void update ( void  )

Take a measurement and store the current sensor values internally. This function must be called prior to retrieving any sensor values, for example getTemperature().

void setTemperatureOSR ( MS5803_OSR_T  osr)

Set the output sampling resolution of the temperature measurement. Higher values provide a more precise value. In addition, more precise values require more time to measure. The default set at device intialization is the highest precision supported: MS5803_OSR_4096

Parameters
osrOne of the MS5803_OSR_T values.
void setPressureOSR ( MS5803_OSR_T  osr)

Set the output sampling resolution of the pressure measurement. Higher values provide a more precise value. In addition, more precise values require more time to measure. The default set at device intialization is the highest precision supported: MS5803_OSR_4096

Parameters
osrOne of the MS5803_OSR_T values.
float getTemperature ( void  )

Return the latest measured temperature. update() must have been called prior to calling this function. The returned value is in degrees Celsius.

Returns
Temperature in degrees C
float getPressure ( )

Return the latest measured pressure. update() must have been called prior to calling this function. The returned value is in millibars.

Returns
Pressure in mbar
void loadCoefficients ( )
protected

Load a series of factory installed compensation coefficients. This function is called during ms5803_init(), so it should never need to be called again. It is provided here anyway "just in case".

Parameters
devDevice context.
Returns
UPM Status.
string busRead ( int  cmd,
int  len 
)
protected

Perform a bus read. This function is bus agnostic. It is exposed here for those users wishing to perform their own low level accesses. This is a low level function, and should not be used unless you know what you are doing.

Parameters
cmdThe command or register to access.
cntThe number of bytes to read.
Returns
The data read
void busWrite ( int  cmd,
std::string  data 
)
protected

Perform a bus write. This function is bus agnostic. It is exposed here for those users wishing to perform their own low level accesses. This is a low level function, and should not be used unless you know what you are doing.

Parameters
cmdThe command or register to access.
dataThe string containing the data to write
Collaboration diagram for MS5803:
Collaboration graph
[legend]

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