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, *, address=96)¶ Instance of the MPL3115A2 sensor.
Parameters: 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 sensorimport board import adafruit_mpl3115a2
Once this is done you can define your
board.I2C
object 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
,pressure
andaltitude
attributestemperature = sensor.temperature pressure = sensor.pressure altitude = sensor.altitude
-
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.
-
pressure
¶ Read the barometric pressure detected by the sensor in Pascals.
-
sealevel_pressure
¶ 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.
-
temperature
¶ Read the temperature as measured by the sensor in degrees Celsius.
-