adafruit_lsm303dlh_mag
¶
CircuitPython driver for the LSM303DLH’s magnetometer.
- Author(s): Dave Astels, 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: https://circuitpython.org/downloads
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
class
adafruit_lsm303dlh_mag.
LSM303DLH_Mag
(i2c)[source]¶ Driver for the Driver for the LSM303DLH’s ‘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
LSM303DLH_Mag
class. First you will need to import the libraries to use the sensorimport board import adafruit_lsm303dlh_mag
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_lsm303dlh_mag.LSM303DLH_Mag(i2c)
Now you have access to the
magnetic
attributemag_x, mag_y, mag_z = sensor.magnetic
-
mag_gain
¶ The magnetometer’s gain.
-
mag_rate
¶ The magnetometer update rate.
-
magnetic
¶ The processed magnetometer sensor values. A 3-tuple of X, Y, Z axis values in microteslas that are signed floats.
-