MicroPython MPL3115A2 Library¶
mpl3115a2¶
MicroPython driver for the NXP MPL3115A2 Pressure and Temperature sensor
Author(s): Jose D. Montoya
-
class micropython_mpl3115a2.mpl3115a2.MPL3115A2(i2c, address: int =
0x60)[source]¶ Driver for the MPL3115A2 Sensor connected over I2C.
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
MPL3115A2class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_mpl3115a2 import mpl3115a2Once this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) mpl3115a2 = mpl3115a2.MPL3115A2(i2c)Now you have access to the attributes
press = mpl3115a2.pressure- 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.
- property oversample_ratio : str¶
Sensor oversample_ratio
Mode
Value
mpl3115a2.OS10b000mpl3115a2.OS20b001mpl3115a2.OS40b010mpl3115a2.OS80b011mpl3115a2.OS160b100mpl3115a2.OS320b101mpl3115a2.OS640b110mpl3115a2.OS1280b111