# 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
1. Instantiate the `DHT11` class with the pin number as constructor parameter.
2. Call `read()` method, which will return `DHT11Result` object with actual values and error code.
For example:
```python
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.
没有合适的资源?快使用搜索试试~ 我知道了~
用于在 Raspberry Pi 上 读取 DHT11传感器的 纯 Python 库_Python_代码_相关文件_下载
共5个文件
py:3个
md:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 67 浏览量
2022-07-13
17:17:40
上传
评论
收藏 4KB ZIP 举报
温馨提示
DHT11 Python 库 这个简单的类可用于从 Raspberry Pi 上的 DHT11 传感器读取温度和湿度值。 用法 DHT11使用引脚号作为构造函数参数实例化类。 调用read()方法,该方法将返回DHT11Result带有实际值和错误代码的对象。 例如: 更多详情、使用方法,请下载后细读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
DHT11_Python-master.zip (5个子文件)
DHT11_Python-master
example.py 535B
dht11
__init__.py 6KB
setup.py 694B
LICENSE.md 1KB
README.md 982B
共 5 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功