MicroPython LIS2MDL Library¶
lis2mdl¶
MicroPython Driver for the ST LIS2MDL Magnetometer sensor
Author(s): Jose D. Montoya
- class micropython_lis2mdl.lis2mdl.AlertStatus(x_high, x_low, y_high, y_low, z_high, z_low)¶
Create new instance of AlertStatus(x_high, x_low, y_high, y_low, z_high, z_low)
- x_high¶
Alias for field number 0
- x_low¶
Alias for field number 1
- y_high¶
Alias for field number 2
- y_low¶
Alias for field number 3
- z_high¶
Alias for field number 4
- z_low¶
Alias for field number 5
-
class micropython_lis2mdl.lis2mdl.LIS2MDL(i2c, address: int =
0x1E)[source]¶ Driver for the LIS2MDL 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
LIS2MDLclass. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_lis2mdl import lis2mdlOnce this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) lis = lis2mdl.LIS2MDL(i2c)Now you have access to the attributes
magx, magy, magz = lis.magnetic- property alert_status¶
Alert Status for interrupts
- property data_rate : str¶
Sensor data_rate
Mode
Value
lis2mdl.RATE_10_HZ0b00lis2mdl.RATE_20_HZ0b01lis2mdl.RATE_50_HZ0b10lis2mdl.RATE_100_HZ0b11
- property interrupt_mode : str¶
Sensor interrupt_mode
Mode
Value
lis2mdl.INT_DISABLED0b0lis2mdl.INT_ENABLED0b1
- property interrupt_threshold : float¶
The threshold (in microteslas) for magnetometer interrupt generation. Given value is compared against all axes in both the positive and negative direction
- property interrupt_triggered¶
Retturn True when an interrupt is triggered
- property low_pass_filter_mode : str¶
Sensor low_pass_filter_mode. Default DISABLED: Values:
DISABLED : ODR/2
ENABLED : ODR/4
Mode
Value
lis2mdl.LPF_DISABLED0b0lis2mdl.LPF_ENABLED0b1
- property low_power_mode : str¶
DISABLED
Mode
Value
lis3mdl.LP_DISABLED0b0lis3mdl.LP_ENABLED0b1- Type:¶
Sensor low_power_mode. Default value