pyupm_mpl3115a2 module

class pyupm_mpl3115a2.MPL3115A2(bus, devAddr=96, mode=6)[source]

Bases: object

API for the MPL3115A2 Atmospheric Pressure Sensor.

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.

C++ includes: mpl3115a2.hpp

convertPaToinHg(fPressure)[source]

float convertPaToinHg(float fPressure)

Converts pressure from Pa*100 to inHg*10000 This is set for 15degC (Pa = 0.0002961 in Hg) TODO: Change the function to add temperature calibration

fPressure: Pressure in Pa

convertTempCtoF(fTemp)[source]

float convertTempCtoF(float fTemp)

Converts temperature from degC*1000 to degF*1000

fTemp: Temperature in degC

dumpSensor()[source]

void dumpSensor(void)

Dumps out the I2C register block to stdout

getAltitude(sealevelPressure=101325.0)[source]

float getAltitude(float sealevelPressure=101325.0)

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

sealevelPressure: Current sea level pressure

getOversampling()[source]

uint8_t getOversampling(void)

Returns the current oversampling value

getPressure(bSampleData=True)[source]

float getPressure(int bSampleData=true)

Reads the current pressure value from MPL3115A2 [Pa]

bSampleData: Sets non-zero to a sample reading

getPressureMax()[source]

float getPressureMax(void)

Reads the maximum measured pressure [Pa]

getPressureMin()[source]

float getPressureMin(void)

Reads the minimum measured pressure [Pa]

getPressureReg(reg)[source]

int32_t getPressureReg(int reg)

Reads the pressure value from MPL3115A2 [Pa * 100]

reg: Base address of the pressure register

getSealevelPressure(altitudeMeters=0.0)[source]

float getSealevelPressure(float altitudeMeters=0.0)

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

altitudeMeters: Altitude in meters

getTempReg(reg)[source]

int32_t getTempReg(int reg)

Reads the temperature value from MPL3115A2 [degC * 1000]

reg: Base address of the temperature register

getTemperature(bSampleData=True)[source]

float getTemperature(int bSampleData=true)

Reads the current temperature value from MPL3115A2 [degC]

bSampleData: Sets non-zero to a sample reading

getTemperatureMax()[source]

float getTemperatureMax(void)

Reads the maximum measured temperature [degC]

getTemperatureMin()[source]

float getTemperatureMin(void)

Reads the minimum measured temperature [degC]

i2cReadReg_16(reg)[source]

uint16_t i2cReadReg_16(int reg)

Reads two bytes from an I2C register

reg: Address of the register

i2cReadReg_8(reg)[source]

uint8_t i2cReadReg_8(int reg)

Reads a one-byte register

reg: Address of the register

i2cWriteReg(reg, value)[source]

mraa::Result i2cWriteReg(uint8_t reg, uint8_t value)

Writes one byte to an I2C register

reg: Address of the register

value: Byte to be written

resetSensor()[source]

int resetSensor(void)

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.

sampleData()[source]

int sampleData(void)

Initiates a temperature/pressure mesasurement and waits for the function to complete. Temperature and pressure registers can be read after this call.

setOversampling(oversampling)[source]

void setOversampling(uint8_t 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

oversampling: New oversampling value

testSensor()[source]

int testSensor(void)

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