adafruit_lsm9ds1
CircuitPython module for the LSM9DS1 accelerometer, magnetometer, gyroscope. Based on the driver from: https://github.com/adafruit/Adafruit_LSM9DS1
See examples/simpletest.py for a demo of the usage.
Author(s): Tony DiCola
Hardware:
Adafruit 9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1 (Product ID: 3387)
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
Driver for the LSM9DS1 accelerometer, magnetometer, gyroscope.
The accelerometer range. Must be a value of:
ACCELRANGE_2G
ACCELRANGE_4G
ACCELRANGE_8G
ACCELRANGE_16G
The accelerometer X, Y, Z axis values as a 3-tuple of \(m/s^2\) values.
The gyroscope X, Y, Z axis values as a 3-tuple of rad/s values.
The gyroscope scale. Must be a value of:
GYROSCALE_245DPS
GYROSCALE_500DPS
GYROSCALE_2000DPS
The magnetometer gain. Must be a value of:
MAGGAIN_4GAUSS
MAGGAIN_8GAUSS
MAGGAIN_12GAUSS
MAGGAIN_16GAUSS
The magnetometer X, Y, Z axis values as a 3-tuple of gauss values.
Read the raw accelerometer sensor values and return it as a 3-tuple of X, Y, Z axis values that are 16-bit unsigned values. If you want the acceleration in nice units you probably want to use the acceleration property!
Read the raw gyroscope sensor values and return it as a 3-tuple of X, Y, Z axis values that are 16-bit unsigned values. If you want the gyroscope in nice units you probably want to use the gyro property!
Read the raw magnetometer sensor values and return it as a 3-tuple of X, Y, Z axis values that are 16-bit unsigned values. If you want the magnetometer in nice units you probably want to use the magnetic property!
Read the raw temperature sensor value and return it as a 12-bit signed value. If you want the temperature in nice units you probably want to use the temperature property!
The temperature of the sensor in degrees Celsius.
Driver for the LSM9DS1 connect over I2C.
i2c (I2C) – The I2C bus the device is connected to
mag_address (int) – A 8-bit integer that represents the i2c address of the LSM9DS1’s magnetometer. Options are limited to 0x1C
or 0x1E
Defaults to 0x1E
.
xg_address (int) – A 8-bit integer that represents the i2c address of the LSM9DS1’s accelerometer and gyroscope. Options are limited to 0x6A
or 0x6B
. Defaults to 0x6B
.
Quickstart: Importing and using the device
Here is an example of using the
LSM9DS1
class. First you will need to import the libraries to use the sensorimport board import adafruit_lsm9ds1Once 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_lsm9ds1.LSM9DS1_I2C(i2c)Now you have access to the
acceleration
,magnetic
gyro
andtemperature
attributesacc_x, acc_y, acc_z = sensor.acceleration mag_x, mag_y, mag_z = sensor.magnetic gyro_x, gyro_y, gyro_z = sensor.gyro temp = sensor.temperature
Driver for the LSM9DS1 connect over SPI.
spi (SPI) – The SPI bus the device is connected to
mcs (DigitalInOut) – The digital output pin connected to the LSM9DS1’s CSM (Chip Select Magnetometer) pin.
xgcs (DigitalInOut) – The digital output pin connected to the LSM9DS1’s CSAG (Chip Select Accelerometer/Gyroscope) pin.
Quickstart: Importing and using the device
Here is an example of using the
LSM9DS1
class. First you will need to import the libraries to use the sensorimport board import adafruit_lsm9ds1Once this is done you can define your
board.SPI
object and define your sensor objectspi = board.SPI() sensor = adafruit_lsm9ds1.LSM9DS1_SPI(spi)Now you have access to the
acceleration
,magnetic
gyro
andtemperature
attributesacc_x, acc_y, acc_z = sensor.acceleration mag_x, mag_y, mag_z = sensor.magnetic gyro_x, gyro_y, gyro_z = sensor.gyro temp = sensor.temperature
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4