Skip to content

MPL3115A2 Module

This module contains the driver for NXP MPL3115A2 Pressure, Altitude and Temperature sensor.

The MPL3115A2 is capable of direct I2C communication; the pressure and temperature data is fed into a high resolution ADC to provide fully compensated and digitized outputs for pressure in Pascals and temperature in °C.

The compensated pressure output can then be converted to altitude (utilizing the formula stated in Section 8.1.3 “Pressure/altitude” of the datasheet or putting the sensor in altimeter operating mode) provided in meters.

class MPL3115A2

class MPL3115A2(i2cdrv, addr=0x60, clk=400000)

Creates an instance of a new MPL3115A2.

Arguments:

  • i2cdrv – I2C Bus used ‘( I2C0, … )’
  • addr – Slave address, default 0x60
  • clk – Clock speed, default 400kHz

Example:

from nxp.mpl3115a2 import mpl3115a2

...

mpl = mpl3115a2.MPL3115A2(I2C0)
mpl.start()
mpl.init()
alt = mpl.get_alt()
pres = mpl.get_pres()
MPL3115A2.init

init(osr=0)

Initialize the MPL3115A2 setting the oversample rate value.

Arguments: osr – set the oversample rate value (from 0 to 7), default 0.

OSR Value Oversample Ratio Data Ready
0 1 6 ms
1 2 10 ms
2 4 18 ms
3 8 34 ms
4 16 66 ms
5 32 130 ms
6 64 258 ms
7 128 512 ms
MPL3115A2.get_raw_alt

get_raw_alt()

Retrieves the current altitude data from the sensor as raw value.

Returns raw_a.

get_raw_pres()

Retrieves the current pressure data from the sensor as raw value.

Returns raw_p.

MPL3115A2.get_raw_temp

get_raw_temp()

Retrieves the current temperature data from the sensor as raw value.

Returns raw_t.

MPL3115A2.get_alt

get_alt()

Calculates, from measured pressure, the current altitude data as value in meters.

Returns altitude.

MPL3115A2.get_pres

get_pres()

Retrieves the current pressure data from the sensor as calibrate value in Pa.

Returns pres.

MPL3115A2.get_temp

get_temp()

Retrieves the current temperature data from the sensor as calibrate value in °C.

Returns temp.