adafruit_lis2mdl
¶
CircuitPython driver for the LIS2MDL 3-axis magnetometer.
- Author(s): Bryan Siepert
Implementation Notes¶
Hardware:
- Adafruit Triple-axis Accelerometer+Magnetometer (Compass) Board - LSM303 (Product ID: 1120)
- Adafruit FLORA Accelerometer/Compass Sensor - LSM303 - v1.0 (Product ID: 1247)
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_lis2mdl.
DataRate
[source]¶ Data rate choices to set using
data_rate
-
Rate_100_HZ
¶ 100 Hz
-
Rate_10_HZ
¶ 10 Hz
-
Rate_20_HZ
¶ 20 Hz
-
Rate_50_HZ
¶ 50 Hz
-
-
class
adafruit_lis2mdl.
LIS2MDL
(i2c)[source]¶ Driver for the LIS2MDL 3-axis magnetometer.
Parameters: i2c (I2C) – The I2C bus the device is connected to Quickstart: Importing and using the device
Here is an example of using the
LIS2MDL
class. First you will need to import the libraries to use the sensorimport board import adafruit_lis2mdl
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA sensor = adafruit_lis2mdl.LIS2MDL(i2c)
Now you have access to the
magnetic
attributemag_x, mag_y, mag_z = sensor.magnetic
-
data_rate
¶ The magnetometer update rate.
-
faults
¶ A tuple representing interrupts on each axis in a positive and negative direction
(x_hi, y_hi, z_hi, x_low, y_low, z_low, int_triggered)
-
interrupt_enabled
¶ Enable or disable the magnetometer interrupt
-
interrupt_threshold
¶ The threshold (in microteslas) for magnetometer interrupt generation. Given value is compared against all axes in both the positive and negative direction
-
low_power
¶ Enables and disables low power mode
-
magnetic
¶ The processed magnetometer sensor values. A 3-tuple of X, Y, Z axis values in microteslas that are signed floats.
-
x_offset
¶ An offset for the X-Axis to subtract from the measured value to correct for magnetic interference
-
y_offset
¶ An offset for the Y-Axis to subtract from the measured value to correct for magnetic interference
-
z_offset
¶ An offset for the Z-Axis to subtract from the measured value to correct for magnetic interference
-