CircuitPython driver for the LSM303DLH’s magnetometer.
- Author(s): Dave Astels, Bryan Siepert
- 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
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_Magclass. First you will need to import the libraries to use the sensor
import board import adafruit_lsm303dlh_mag
Once this is done you can define your
board.I2Cobject and define your sensor object
i2c = board.I2C() # uses board.SCL and board.SDA sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
Now you have access to the
mag_x, mag_y, mag_z = sensor.magnetic
The magnetometer’s gain.
The magnetometer update rate.
The processed magnetometer sensor values. A 3-tuple of X, Y, Z axis values in microteslas that are signed floats.