项目
在 GitHub 查看
szazo/DHT11_Python
关于
Pure Python library for reading DHT11 sensor on Raspberry Pi
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文DHT11 Python library
This simple class can be used for reading temperature and humidity values from DHT11 sensor on Raspberry Pi.
Installation
To install, just run following:
pip install dht11
Usage
- Instantiate the
DHT11class with the pin number as constructor parameter. - Call
read()method, which will returnDHT11Resultobject with actual values and error code.
For example:
import RPi.GPIO as GPIO
import dht11
# initialize GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()
# read data using pin 14
instance = dht11.DHT11(pin = 14)
result = instance.read()
if result.is_valid():
print("Temperature: %-3.1f C" % result.temperature)
print("Humidity: %-3.1f %%" % result.humidity)
else:
print("Error: %d" % result.error_code)
For working example, see dht11_example.py (you probably need to adjust pin for your configuration)
License
This project is licensed under the terms of the MIT license.
探索相关项目
加载中…