CircuitPython module for the MPL3115A2 barometric pressure & temperature sensor.

  • Author(s): Tony DiCola

Implementation Notes


Software and Dependencies:

class adafruit_mpl3115a2.MPL3115A2(i2c, *, address=96)

Instance of the MPL3115A2 sensor.

  • i2c (I2C) – The I2C bus the MPL3115A2 is connected to.
  • address (int) – The I2C device address. Defaults to 0x60

Quickstart: Importing and using the MPL3115A2

Here is an example of using the MPL3115A2 class. First you will need to import the libraries to use the sensor

import board
import adafruit_mpl3115a2

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA
sensor = adafruit_mpl3115a2.MPL3115A2(i2c)

Now you have access to the temperature, pressure and altitude attributes

temperature = sensor.temperature
pressure = sensor.pressure
altitude = sensor.altitude

Read the altitude as calculated based on the sensor pressure and previously configured pressure at sea-level. This will return a value in meters. Set the sea-level pressure by updating the sealevel_pressure property first to get a more accurate altitude value.


Read the barometric pressure detected by the sensor in Pascals.


Read and write the pressure at sea-level used to calculate altitude. You must look this up from a local weather or meteorological report for the best accuracy. This is a value in Pascals.


Read the temperature as measured by the sensor in degrees Celsius.