跳转到主要内容

CircuitPython库,用于LSM9DS0加速度计、磁力计、陀螺仪。

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

CircuitPython模块,用于LSM9DS0加速度计、磁力计、陀螺仪。

依赖项

此驱动程序依赖于

请确保所有依赖项都在CircuitPython文件系统中可用。这可以通过下载 Adafruit库和驱动程序捆绑包 来轻松实现。

从PyPI安装

在支持GNU/Linux系统(如Raspberry Pi)上,您可以从PyPI本地安装驱动程序 要为当前用户安装

pip3 install adafruit-circuitpython-lsm9ds0

要系统范围内安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-lsm9ds0

要在当前项目的虚拟环境中安装

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-lsm9ds0

使用示例

import time
import board
import busioimport adafruit_lsm9ds0

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_lsm9ds0.LSM9DS0_I2C(i2c)

while True:
    accel_x, accel_y, accel_z = sensor.acceleration
    mag_x, mag_y, mag_z = sensor.magnetic
    gyro_x, gyro_y, gyro_z = sensor.gyro
    temp = sensor.temperature
    print('Acceleration (m/s^2): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(accel_x, accel_y, accel_z))
    print('Magnetometer (gauss): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(mag_x, mag_y, mag_z))
    print('Gyroscope (degrees/sec): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(gyro_x, gyro_y, gyro_z))
    print('Temperature: {0:0.3f}C'.format(temp))
    time.sleep(1.0)

文档

此库的API文档可在 Read the Docs 上找到。

有关构建库文档的信息,请参阅 本指南

贡献

欢迎贡献!在为该项目做出贡献之前,请阅读我们的行为准则,以帮助该项目保持友好。

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分布

adafruit-circuitpython-lsm9ds0-2.2.17.tar.gz (28.6 kB 查看哈希值)

上传时间 源代码

构建分布

adafruit_circuitpython_lsm9ds0-2.2.17-py3-none-any.whl (7.3 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面