lsm303d-python
Python library for the LSM303D I2C accelerometer/magnetometer
Usage
- Install the Python
smbusmodule for your platform (sudo apt install python-smbusfor Debian or Ubuntu Linux) pip install lsm303-pythonsudo lsm303_test
Example Code
import time
import smbus
import lsm303
i2c_channel = 1
bus = smbus.SMBus(i2c_channel)
# Will raise OSError if device is not connected
device = lsm303.LSM303(bus)
while True:
# Returns x,y,z tuple with values in degrees/second
accel_data = device.read_accel()
# Returns x,y,z tuple with values in microtesla
mag_data = device.read_mag()
print(
[round(v, 2) for v in accel_data],
[round(v, 2) for v in mag_data]
)
time.sleep(0.1)
Release files for lsm303-python 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lsm303-python-1.0.0.tar.gz | 3.5 kB | Details |
Release files / lsm303-python-1.0.0.tar.gz
| Download URL | lsm303-python-1.0.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c34ecc62d7d048ddb17d9a0b66934f0f64e137ed89a39e5836d8af405c0685fe
|
|
BLAKE2b-256 checksum How to use checksums |
7fe054fc14479c95532ae33e4a3f5eef61e48eeb3e352565a63ed8b4c0d3baa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2
|