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.


Only smbus2 other than Python.


pip3 install lis3dh


From command line;


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:

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


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.



Project details

Download files

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

Files for lis3dh, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size lis3dh-0.2-py3-none-any.whl (5.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size lis3dh-0.2.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page