adafruit_lis3mdl
¶
CircuitPython helper library for the LIS3MDL 3-axis magnetometer
Author(s): Bryan Siepert
Implementation Notes¶
Hardware: * Adafruit Adafruit LSM6DS33 + LIS3MDL - 9 DoF IMU (Product ID: 4485)
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
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class adafruit_lis3mdl.LIS3MDL(i2c_bus: I2C, address: int = micropython.const)¶
Driver for the LIS3MDL 3-axis magnetometer.
- Parameters:
Quickstart: Importing and using the device
Here is an example of using the
LIS3MDL
class. First you will need to import the libraries to use the sensorimport board import adafruit_lis3mdl
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() sensor = adafruit_lis3mdl.LIS3MDL(i2c)
Now you have access to the
magnetic
attributemag_x, mag_y, mag_z = sensor.magnetic
- property magnetic: Tuple[float, float, float]¶
The processed magnetometer sensor values. A 3-tuple of X, Y, Z axis values in microteslas that are signed floats.
- property operation_mode: int¶
The operating mode for the sensor, controlling how measurements are taken. Must be an
OperationMode
. See the theOperationMode
document for additional details
- property performance_mode: int¶
Sets the ‘performance mode’ of the sensor. Must be a
PerformanceMode
. Note thatperformance_mode
affects the available data rate and will be automatically changed by settingdata_rate
to certain values.
- class adafruit_lis3mdl.OperationMode¶
Options for
operation_mode
Operation Mode
Meaning
OperationMode.CONTINUOUS
Measurements are made continuously at the given
data_rate
OperationMode.SINGLE
Setting to
SINGLE
takes a single measurement.OperationMode.POWER_DOWN
Halts measurements.
magnetic
will return the last measurement
- class adafruit_lis3mdl.Rate¶
Options for
data_rate
Rate
Meaning
RATE_0_625_HZ
0.625 HZ
RATE_1_25_HZ
1.25 HZ
RATE_2_5_HZ
2.5 HZ
RATE_5_HZ
5 HZ
RATE_10_HZ
10 HZ
RATE_20_HZ
20 HZ
RATE_40_HZ
40 HZ
RATE_80_HZ
80 HZ
RATE_155_HZ
155 HZ ( Sets
PerformanceMode
toMODE_ULTRA
)RATE_300_HZ
300 HZ ( Sets
PerformanceMode
toMODE_HIGH
)RATE_560_HZ
560 HZ ( Sets
PerformanceMode
toMODE_MEDIUM
)RATE_1000_HZ
1000 HZ ( Sets
PerformanceMode
toMODE_LOW_POWER
)