API Reference
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, performance_mode: PerformanceMode = 3, data_rate: Rate = 1, range_: Range = 0, operation_mode: OperationMode = 0)
Driver for the LIS3MDL 3-axis magnetometer.
- Parameters:
Quickstart: Importing and using the device
Here is an example of using the
LIS3MDLclass. 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.I2Cobject and define your sensor objecti2c = board.I2C() sensor = adafruit_lis3mdl.LIS3MDL(i2c)
Now you have access to the
magneticattributemag_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 theOperationModedocument for additional details
- property performance_mode: int
Sets the ‘performance mode’ of the sensor. Must be a
PerformanceMode. Note thatperformance_modeaffects the available data rate and will be automatically changed by settingdata_rateto certain values.
- class adafruit_lis3mdl.OperationMode
Options for
operation_modeOperation Mode
Meaning
OperationMode.CONTINUOUSMeasurements are made continuously at the given
data_rateOperationMode.SINGLESetting to
SINGLEtakes a single measurement.OperationMode.POWER_DOWNHalts measurements.
magneticwill return the last measurement
- class adafruit_lis3mdl.Rate
Options for
data_rateRate
Meaning
RATE_0_625_HZ0.625 HZ
RATE_1_25_HZ1.25 HZ
RATE_2_5_HZ2.5 HZ
RATE_5_HZ5 HZ
RATE_10_HZ10 HZ
RATE_20_HZ20 HZ
RATE_40_HZ40 HZ
RATE_80_HZ80 HZ
RATE_155_HZ155 HZ ( Sets
PerformanceModetoMODE_ULTRA)RATE_300_HZ300 HZ ( Sets
PerformanceModetoMODE_HIGH)RATE_560_HZ560 HZ ( Sets
PerformanceModetoMODE_MEDIUM)RATE_1000_HZ1000 HZ ( Sets
PerformanceModetoMODE_LOW_POWER)