adafruit_lsm6ds

CircuitPython helper library for the LSM6DS family of motion sensors from ST

  • Author(s): Bryan Siepert, Jose David M.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_lsm6ds.LSM6DS(i2c_bus: I2C, address: int = micropython.const, ucf: str = None)

Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.

Parameters:
  • i2c_bus (I2C) – The I2C bus the LSM6DSOX is connected to.

  • address (int) – TThe I2C device address. Defaults to 0x6A

pedometer_steps

The number of steps detected by the pedometer. You must enable with pedometer_enable before calling. Use pedometer_reset to reset the number of steps

reset() None

Resets the sensor’s configuration into an initial state

property acceleration: Tuple[float, float, float]

The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2.

property gyro: Tuple[float, float, float]

The x, y, z angular velocity values returned in a 3-tuple and are in radians / second

property accelerometer_range: int

Adjusts the range of values that the sensor can measure, from +/- 2G to +/-16G Note that larger ranges will be less accurate. Must be an AccelRange

property gyro_range: int

Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 2000 degrees/s. Note that larger ranges will be less accurate. Must be a GyroRange.

property accelerometer_data_rate: int

Select the rate at which the accelerometer takes measurements. Must be a Rate

property gyro_data_rate: int

Select the rate at which the gyro takes measurements. Must be a Rate

property pedometer_enable: bool

Whether the pedometer function on the accelerometer is enabled

property high_pass_filter: int

The high pass filter applied to accelerometer data

property temperature: float

Temperature in Celsius

load_mlc(ucf)

Load MLC configuration file into sensor

read_mlc_output()

Read MLC results

This module provides the adafruit_lsm6ds.ism330dhcx subclass of LSM6DS sensors

class adafruit_lsm6ds.ism330dhcx.ISM330DHCX(i2c_bus: I2C, address: int = micropython.const)

Driver for the ISM330DHCX 6-axis accelerometer and gyroscope.

Parameters:
  • i2c_bus (I2C) – The I2C bus the device is connected to.

  • address (int) – The I2C device address. Defaults to 0x6A

Quickstart: Importing and using the device

Here is an example of using the ISM330DHCX class. First you will need to import the libraries to use the sensor

import board
from adafruit_lsm6ds.ism330dhcx import ISM330DHCX

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = ISM330DHCX(i2c)

Now you have access to the acceleration and gyro: attributes

acc_x, acc_y, acc_z = sensor.acceleration
gyro_x, gyro_z, gyro_z = sensor.gyro
property gyro_range: int

Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 4000 degrees/s. Note that larger ranges will be less accurate. Must be a GyroRange. 4000 DPS is only available for the ISM330DHCX

This module provides the adafruit_lsm6ds.lsm6ds33 subclass of LSM6DS sensors

class adafruit_lsm6ds.lsm6ds33.LSM6DS33(i2c_bus: I2C, address: int = micropython.const, ucf: str = None)

Driver for the LSM6DS33 6-axis accelerometer and gyroscope.

Parameters:
  • i2c_bus (I2C) – The I2C bus the LSM6DS33 is connected to.

  • address (int) – The I2C device address. Defaults to 0x6A

Quickstart: Importing and using the device

Here is an example of using the LSM6DS33 class. First you will need to import the libraries to use the sensor

import board
from adafruit_lsm6ds.lsm6ds33 import LSM6DS33

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = LSM6DS33(i2c)

Now you have access to the acceleration and gyro: attributes

acc_x, acc_y, acc_z = sensor.acceleration
gyro_x, gyro_z, gyro_z = sensor.gyro

This module provides the adafruit_lsm6ds.lsm6dso32 subclass of LSM6DS sensors

class adafruit_lsm6ds.lsm6dso32.LSM6DSO32(i2c_bus: I2C, address: int = micropython.const)

Driver for the LSM6DSO32 6-axis accelerometer and gyroscope.

Parameters:
  • i2c_bus (I2C) – The I2C bus the LSM6DSO32 is connected to.

  • address – The I2C device address. Defaults to 0x6A

Quickstart: Importing and using the device

Here is an example of using the LSM6DSO32 class. First you will need to import the libraries to use the sensor

import board
from adafruit_lsm6ds.lsm6dso32 import LSM6DSO32

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = LSM6DSO32(i2c)

Now you have access to the acceleration and gyro: attributes

acc_x, acc_y, acc_z = sensor.acceleration
gyro_x, gyro_z, gyro_z = sensor.gyro

This module provides the adafruit_lsm6ds.lsm6dsox subclass of LSM6DS sensors

class adafruit_lsm6ds.lsm6dsox.LSM6DSOX(i2c_bus: I2C, address: int = micropython.const, ucf: str = None)

Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.

Parameters:
  • i2c_bus (I2C) – The I2C bus the LSM6DSOX is connected to.

  • address (int) – The I2C device address. Defaults to 0x6A

Quickstart: Importing and using the device

Here is an example of using the LSM6DSOX class. First you will need to import the libraries to use the sensor

import board
from adafruit_lsm6ds.lsm6dsox import LSM6DSOX

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = LSM6DSOX(i2c)

Now you have access to the acceleration and gyro: attributes

acc_x, acc_y, acc_z = sensor.acceleration
gyro_x, gyro_z, gyro_z = sensor.gyro