Skip to content

Add LSM6DS3 subclass #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2022
Merged

Add LSM6DS3 subclass #49

merged 1 commit into from
Feb 20, 2022

Conversation

myllyja
Copy link
Contributor

@myllyja myllyja commented Feb 20, 2022

This adds the LSM6DS3 class which is a copy of the LSM6DS33 class with a different chip ID. This makes the library work on the Seeed XIAO nRF52840 Sense board. More info on the IMU can be found in the Seeed Wiki

Tested with "Adafruit CircuitPython 7.2.0-alpha.2 on 2022-02-11; Seeed XIAO nRF52840 Sense with nRF52840"

import board
import busio
import digitalio

from adafruit_lsm6ds.lsm6ds3 import LSM6DS3

# Enable power to the IMU
imupwr = digitalio.DigitalInOut(board.IMU_PWR)
imupwr.direction = digitalio.Direction.OUTPUT
imupwr.value = True

# Create an I2C bus with the IMU pins
imu_i2c = busio.I2C(board.IMU_SCL, board.IMU_SDA)
sensor = LSM6DS3(imu_i2c)

Now the sensor values can be read like the example shows:

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

>>> print(f"accX: {acc_x} accY: {acc_y} accZ: {acc_z}")
accX: -0.165105 accY: -0.0885344 accZ: 10.0822
>>> print(f"gyroX: {gyro_x} gyroY: {gyro_y} gyroZ: {gyro_z}")
gyroX: 0.0129809 gyroY: -0.0316123 gyroZ: -0.00458149

@ladyada
Copy link
Member

ladyada commented Feb 20, 2022

thanks :)

@ladyada ladyada merged commit ccfea10 into adafruit:main Feb 20, 2022
@myllyja myllyja deleted the add-lsm6ds3 branch February 20, 2022 17:52
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 23, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 4.0.2 from 4.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#157 from Neradoc/patch-1
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA260 to 1.3.4 from 1.3.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA260#19 from gpongelli/patch-2
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS to 4.3.0 from 4.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM6DS#49 from myllyja/add-lsm6ds3
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 5.1.8 from 5.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#86 from tekktrik/hotfix/require-python-version-pt2

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.2.2 from 5.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#103 from tekktrik/doc/minor-updates
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_turtle to 2.2.5 from 2.2.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_turtle#29 from FoamyGuy/remove_cp_6_fallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants