Skip to main content

Python3 I2C Driver & Application for LIS3DH Accelerometer

Project description

LIS3DH Accelerometer I2C Driver for Python3

LIS3DH is an accelerometer manufactured by ST Microelectronics. With this driver, you can use LIS3DH with Python3 over I2C.

Dependencies

Only smbus2 other than Python.

Installation

pip3 install lis3dh

Usage

From command line;

run-lis3dh

From Python script;

from lis3dh import LIS3DH, device
from time import sleep

registers = device()
lis = LIS3DH(port=1, scale=registers.CTRL_REG4.SCALE_4G, data_rate=registers.CTRL_REG1.ODR_10Hz)

data = lis.read_dummy_register()
print("DUMMY REG CHECK ERROR: " + str(data)) # 0: No Error, -1: Error

lis.enable_axes(registers.CTRL_REG1.Xen | registers.CTRL_REG1.Yen | registers.CTRL_REG1.Zen)

while lis.read_data_ready_register() == lis.ERROR:
    sleep(0.25)

data = lis.read_all_axes()
print("x(g): {}, y(g): {}, z(g): {}".format(data[0], data[1], data[2]))

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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

lis3dh-0.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lis3dh-0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file lis3dh-0.1.tar.gz.

File metadata

  • Download URL: lis3dh-0.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for lis3dh-0.1.tar.gz
Algorithm Hash digest
SHA256 31c356b5d236b31d4a4ebe70e110446e3044a2713ada6b373e1eec8e48244736
MD5 93d78d0cfddb397f737136219c47b71c
BLAKE2b-256 6791a2958d53610bc3a40d27e5fd83453201d82124765604270fed15e5216b2f

See more details on using hashes here.

File details

Details for the file lis3dh-0.1-py3-none-any.whl.

File metadata

  • Download URL: lis3dh-0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for lis3dh-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 955d067b81a58f8fb9320dc97f0310e7c04a344d96447dea57236d5bde893764
MD5 b7038d20f3448855a02e6c89e3feebe5
BLAKE2b-256 b7f9bc4c49c235c95a878f4a4c3cace3d2729a235b8866f4d787eb27eab31db7

See more details on using hashes here.

Supported by

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