API Reference
adafruit_mpl3115a2
CircuitPython module for the MPL3115A2 barometric pressure & temperature sensor.
Author(s): Tony DiCola
Implementation Notes
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_mpl3115a2.MPL3115A2(i2c: I2C, *, address: int = 96)
Instance of the MPL3115A2 sensor.
- Parameters:
Quickstart: Importing and using the MPL3115A2
Here is an example of using the
MPL3115A2class. First you will need to import the libraries to use the sensorimport board import adafruit_mpl3115a2
Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
Now you have access to the
temperature,pressureandaltitudeattributestemperature = sensor.temperature pressure = sensor.pressure altitude = sensor.altitude
- property altitude: float
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_pressureproperty first to get a more accurate altitude value.