MPL3115A2 Class
- ID: mpl3115a2
- Name: I2C Precision Altimeter
- Category: pressure
- Manufacturer: freescale
- Link: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPL3115A2
- Connection: i2c
Freescale Semiconductor* MPL3115A2 is a high-precision, ultra-low power consumption pressure sensor. Its operating range is 50-110 kPa.
Item Index
Methods
- MPL3115A2
- testSensor
- resetSensor
- dumpSensor
- sampleData
- getPressureReg
- getTempReg
- getPressure
- getTemperature
- getSealevelPressure
- getAltitude
- setOversampling
- getOversampling
- getTemperatureMax
- getTemperatureMin
- getPressureMax
- getPressureMin
- convertTempCtoF
- convertPaToinHg
- i2cWriteReg
- i2cReadReg_16
- i2cReadReg_8
Methods
MPL3115A2
-
bus
-
devAddr
-
mode
Instantiates an MPL3115A2 object
Parameters:
-
bus
NumberNumber of the used bus
-
devAddr
NumberAddress of the used I2C device
-
mode
NumberMPL3115A2 oversampling (6 = 64x)
Returns:
testSensor
()
Number
MPL3115A2 object destructor; basically, it closes the I2C connection. ~MPL3115A2(); no need for this here, as the I2c connection will be closed when the m_i2ControlCtx variable will go out of scope Tests the sensor and tries to determine if the sensor is operating by looking for small variations in the value
Returns:
resetSensor
()
Number
Performs a soft reset of the MPL3115A2 device to ensure it is in a known state. This function can be used to reset the min/max temperature and pressure values.
Returns:
dumpSensor
()
Dumps out the I2C register block to stdout
sampleData
()
Number
Initiates a temperature/pressure mesasurement and waits for the function to complete. Temperature and pressure registers can be read after this call.
Returns:
getPressureReg
-
reg
Reads the pressure value from MPL3115A2 [Pa * 100]
Parameters:
-
reg
NumberBase address of the pressure register
Returns:
getTempReg
-
reg
Reads the temperature value from MPL3115A2 [degC * 1000]
Parameters:
-
reg
NumberBase address of the temperature register
Returns:
getPressure
-
bSampleData
Reads the current pressure value from MPL3115A2 [Pa]
Parameters:
-
bSampleData
NumberSets non-zero to a sample reading
Returns:
getTemperature
-
bSampleData
Reads the current temperature value from MPL3115A2 [degC]
Parameters:
-
bSampleData
NumberSets non-zero to a sample reading
Returns:
getSealevelPressure
-
altitudeMeters
Reads the current pressure and, using a known altitude, calculates the sea level pressure value [Pa] This function should be preceded by the sampleData() call
Parameters:
-
altitudeMeters
NumberAltitude in meters
Returns:
getAltitude
-
sealevelPressure
Reads the current pressure and, using a known sea level pressure, calculates the altitude value [m] This function should be preceded by the sampleData() call
Parameters:
-
sealevelPressure
NumberCurrent sea level pressure
Returns:
setOversampling
-
oversampling
Defines the oversampling setting (ranges from 0 to 7). The value represents 2^n samples (ranging from 1 to 128). The time to calculate a sample is approximately (2^n * 4 + 2) ms
Parameters:
-
oversampling
NumberNew oversampling value
getOversampling
()
Number
Returns the current oversampling value
Returns:
getTemperatureMax
()
Number
Reads the maximum measured temperature [degC]
Returns:
getTemperatureMin
()
Number
Reads the minimum measured temperature [degC]
Returns:
getPressureMax
()
Number
Reads the maximum measured pressure [Pa]
Returns:
getPressureMin
()
Number
Reads the minimum measured pressure [Pa]
Returns:
convertTempCtoF
-
fTemp
Converts temperature from degC1000 to degF1000
Parameters:
-
fTemp
NumberTemperature in degC
Returns:
convertPaToinHg
-
fPressure
Converts pressure from Pa100 to inHg10000 This is set for 15degC (Pa = 0.0002961 in Hg) TODO: Change the function to add temperature calibration
Parameters:
-
fPressure
NumberPressure in Pa
Returns:
i2cWriteReg
-
reg
-
value
Writes one byte to an I2C register
Parameters:
-
reg
NumberAddress of the register
-
value
NumberByte to be written
Returns:
i2cReadReg_16
-
reg
Reads two bytes from an I2C register
Parameters:
-
reg
NumberAddress of the register
Returns:
i2cReadReg_8
-
reg
Reads a one-byte register
Parameters:
-
reg
NumberAddress of the register