https://github.com/stdevpavelmc/dht11_python_opi.gpio
A DTH11 python lib using the OPi.GPIO lib, for armbian and Orange Pi boards
https://github.com/stdevpavelmc/dht11_python_opi.gpio
Last synced: 11 months ago
JSON representation
A DTH11 python lib using the OPi.GPIO lib, for armbian and Orange Pi boards
- Host: GitHub
- URL: https://github.com/stdevpavelmc/dht11_python_opi.gpio
- Owner: stdevPavelmc
- License: mit
- Created: 2020-04-30T03:57:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T04:01:05.000Z (about 6 years ago)
- Last Synced: 2025-04-06T21:19:47.259Z (about 1 year ago)
- Language: Python
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DHT11 Python library tuned to be used with the OPi.GPIO lib for Orange Pi SBC
This simple class can be used for reading temperature and humidity values from DHT11 sensor on any of the supported SBC that works with the Orange Pi Boards and OPi.GPIO lib
# Installation
To install, clone the repository, cd into it, and run:
```
python3 -m pip install .
```
# 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 OPi.GPIO as GPIO
import dht11
# initialize GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setboard(GPIO.PRIME) # Select Orange Pi PC board to use
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.
# Retribution
This lib is based on the lib by [@szazo on github](https://github.com/szazo/DHT11_Python.git) and adapted to work with the OPi.GPIO lib