Skip to content

Fixed LSM6DS3 to LSM6DS3TR-C #50

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 2 commits into from
Feb 25, 2022
Merged

Conversation

myllyja
Copy link
Contributor

@myllyja myllyja commented Feb 25, 2022

Originally I read that the "Seeed XIAO nRF52840 Sense" had an LSM6DS3 IMU, but upon further testing, it's actually an LSM6DS3TR-C model so I changed this class to match the chip id to the correct one. The specific sensor model is mentioned in the listing and wiki article.

I've added an example for using the library with the XIAO BLE Sense board which is using a separate IMU I2C bus and an IMU_PWR pin to enable the IMU.

Also now the pedometer example works with this board using the correct register.

Adafruit CircuitPython 7.2.0-rc.2 on 2022-02-23; Seeed XIAO nRF52840 Sense with nRF52840
>>>
>>> import board
>>> import digitalio
>>> import busio
>>> from adafruit_lsm6ds.lsm6ds3trc import LSM6DS3TRC
>>>
>>> # On the Seeed XIAO nRF52840 Sense the LSM6DS3TR-C IMU is connected on a separate
>>> # I2C bus and it has its own power pin that we need to enable.
>>> imupwr = digitalio.DigitalInOut(board.IMU_PWR)
>>> imupwr.direction = digitalio.Direction.OUTPUT
>>> imupwr.value = True
>>>
>>> imu_i2c = busio.I2C(board.IMU_SCL, board.IMU_SDA)
>>> sensor = LSM6DS3TRC(imu_i2c)
>>>
>>>
>>> sensor.pedometer_enable = True
>>>
>>> print("Steps: ", sensor.pedometer_steps)
Steps:  0
>>> print("Steps: ", sensor.pedometer_steps)
Steps:  0
>>> print("Steps: ", sensor.pedometer_steps)
Steps:  7
>>> print("Steps: ", sensor.pedometer_steps)
Steps:  9
>>> print("Steps: ", sensor.pedometer_steps)
Steps:  11

This chip has slightly different registers.
@ladyada
Copy link
Member

ladyada commented Feb 25, 2022

hiya its correct as is, TR-C just means its on tape and reel

@myllyja
Copy link
Contributor Author

myllyja commented Feb 25, 2022

Hmm, the datasheets have different registers and I cannot get the Seeed XIAO nRF52840 Sense board IMU to work with the current pedometer_enable register bit in the main class.

If we check the lsm6ds5tr-c datasheet the PEDO_EN bit is in the CTRL10_C (19h) and not in the TAP_CFG (58h) one where it was in the lsm6ds3 datasheet.

And the Seeed Arduino library for LSM6DS3 seems to have two different chip IDs for different models/versions, 0x69 and 0x6A

Also the other Adafruit library seems to indicate that the LSM6DS3 chip id is 0x69, but this XIAO board says it has a 0x6A chip.

Adafruit CircuitPython 7.2.0-rc.2 on 2022-02-23; Seeed XIAO nRF52840 Sense with nRF52840
>>>
>>> import board
>>> import digitalio
>>> import busio
>>> from adafruit_lsm6ds.lsm6ds3trc import LSM6DS3TRC
>>>
>>> imupwr = digitalio.DigitalInOut(board.IMU_PWR)
>>> imupwr.direction = digitalio.Direction.OUTPUT
>>> imupwr.value = True
>>>
>>> imu_i2c = busio.I2C(board.IMU_SCL, board.IMU_SDA)
>>> sensor = LSM6DS3TRC(imu_i2c)
>>>
>>> hex(sensor._chip_id)
'0x6a'

@ladyada
Copy link
Member

ladyada commented Feb 25, 2022

ok thats very wierd but we believe you!

@myllyja
Copy link
Contributor Author

myllyja commented Feb 25, 2022

When I tested the Seeeds own library example it seems to enable the pedometer "accidentally" by putting 0x3C into CTRL10_C here which enabled a few other things and those comments in the example match the LSM6DS3 model registers, but not the LSM6DS3TR-C thing in the XIAO Sense.

I was trying to look for other model numbers for it, but the LSM6DS3TR-C seems to be the only item on the manufacturers site, those other LSM6DS3 items can't be found anymore, except for some cached pages for LSM6DS3 and LSM6DS33

@ladyada ladyada merged commit 7261e46 into adafruit:main Feb 25, 2022
@myllyja myllyja deleted the fix-lsm6ds3trc branch February 25, 2022 23:22
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 2, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS to 4.3.1 from 4.3.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM6DS#50 from myllyja/fix-lsm6ds3trc

Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.10.7 from 1.10.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#96 from ladyada/main
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL6180X to 1.4.2 from 1.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL6180X#27 from tekktrik/fix-example-file

Updating https://github.com/adafruit/Adafruit_CircuitPython_asyncio to 0.5.7 from 0.5.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_asyncio#20 from dhalbert/_asyncio
  > Fixed readthedocs build

Updating https://github.com/adafruit/Adafruit_CircuitPython_MacroPad to 2.0.6 from 2.0.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_MacroPad#38 from xelwarto/main
  > Fixed readthedocs build
  > Post-patch cleanup
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.2.3 from 5.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#104 from fabaff/permission
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