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, address=<sphinx.ext.autodoc.importer._MockObject object>)¶ Driver for the LIS3MDL 3-axis magnetometer.
Parameters: - i2c_bus (I2C) – The I2C bus the LIS3MDL is connected to.
- address – The I2C device address. Defaults to
0x1C
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
-
data_rate
¶ The rate at which the sensor takes measurements. Must be a
Rate
-
magnetic
¶ The processed magnetometer sensor values. A 3-tuple of X, Y, Z axis values in microteslas that are signed floats.
-
operation_mode
¶ The operating mode for the sensor, controlling how measurements are taken. Must be an
OperationMode
. See the theOperationMode
document for additional details
-
performance_mode
¶ 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.
-
range
¶ The measurement range for the magnetic sensor. Must be a
Range
-
reset
()¶ Reset the sensor to the default state set by the library
-
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
)