跳转到主要内容

Sensirion SHT4x 温湿度传感器的 Python 库

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

Sensirion SHT4x 温湿度传感器的 Python 库

依赖项

此驱动程序依赖于

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

从PyPI安装

在支持的GNU/Linux系统(如树莓派)上,您可以从PyPI 本地安装驱动程序。为当前用户安装

pip3 install adafruit-circuitpython-sht4x

要系统性地安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-sht4x

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

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

使用示例

import time
import board
import adafruit_sht4x

i2c = board.I2C()   # uses board.SCL and board.SDA
sht = adafruit_sht4x.SHT4x(i2c)
print("Found SHT4x with serial number", hex(sht.serial_number))

sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION
# Can also set the mode to enable heater
# sht.mode = adafruit_sht4x.Mode.LOWHEAT_100MS
print("Current mode is: ", adafruit_sht4x.Mode.string[sht.mode])

while True:
    temperature, relative_humidity = sht.measurements
    print("Temperature: %0.1f C" % temperature)
    print("Humidity: %0.1f %%" % relative_humidity)
    print("")
    time.sleep(1)

文档

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

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

贡献

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

项目详情


下载文件

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

源代码分发

adafruit_circuitpython_sht4x-1.0.20.tar.gz (27.9 kB 查看哈希值)

上传时间 源代码

构建分发

adafruit_circuitpython_sht4x-1.0.20-py3-none-any.whl (6.3 kB 查看哈希值)

上传时间 Python 3

支持者