Skip to main content

MicroPython device library for the LSM6DS3TR-C IMU

Project description

LSM6DS3TR-C MicroPython Library

The LSM6DS3TR-C is an always-on 3D accelerometer and 3D gyroscope that includes additional built-in functions such as:

  • Pedometer
  • Tap and double tap recognition
  • Significant motion and tilt detection
  • Free-fall detection

Example Program

An example showing the basic setup and reading of the Gyro and Accelerometer.

from machine import I2C
from lsm6ds3 import LSM6DS3, NORMAL_MODE_104HZ
import time

i2c = I2C(0, scl=13, sda=12)
sensor = LSM6DS3(i2c, mode=NORMAL_MODE_104HZ)

while True:
    ax, ay, az, gx, gy, gz = sensor.get_readings()
    print("Accelerometer\nX:{}, Y:{}, Z:{}\nGyro\nX:{}, Y:{}, Z{}\n\n ".format(ax, ay, az, gx, gy, gz))
    time.sleep(1.0)

Functions

.get_readings()

Get the current X Y Z values from the Accelerometer and Gyro. Returns ax ay az gx gy gz

Output:

>>> sensor.get_readings()
(-5839, -5124, -10199, 192, 12030, 24831)

.get_step_count()

Get the current number of steps detected by the sensor. Returns an integer value.

Output:

>>> sensor.get_step_count()
29

.reset_step_count()

Reset the step counter to 0

.tilt_detected()

Returns 1 if the sensor detects tilt on the X Y or Z axis and 0 if no tilt detected.

.sig_motion_detected()

Returns 1 if the sensor detects significant motion and 0 if no significant motion detected.

.single_tap_detected()

Returns 1 if the sensor detects a single tap on the X Y or Z axis and 0 if no tap detected.

.double_tap_detected()

Returns 1 if the sensor detects a double tap on the X Y or Z axis and 0 if no double tap detected.

.freefall_detected()

Returns 1 if the sensor detects it is currently in free fall and 0 if no free fall detected.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lsm6ds3_micropython-0.0.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

lsm6ds3_micropython-0.0.2-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file lsm6ds3_micropython-0.0.2.tar.gz.

File metadata

  • Download URL: lsm6ds3_micropython-0.0.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for lsm6ds3_micropython-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0bb2308252a97aac9cc9c6a56a108da18f2513ab6536cccf1b7bc4ff941590af
MD5 ee2c396fe4b8e17c1c4441e7b83ce42e
BLAKE2b-256 611155f6fb6f7ded2b415540b10b750b3828c41dff0fce61b784472c57640504

See more details on using hashes here.

File details

Details for the file lsm6ds3_micropython-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for lsm6ds3_micropython-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9f9422a6581edde858c86044804c0b26d2df4d55f2e48ad0560c86ebf5bae767
MD5 6b318287e21b8621727032577366a2f0
BLAKE2b-256 1aaf95e4a6fa2cec0fb14e2dd16b360ceda76b98f397419ee8684f5a91ceb957

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page