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
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
-
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 theOperationModedocument for additional details
-
performance_mode¶ 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.
-
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_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)