Skip to main content

Pure Python library for reading DHT11 sensor on Raspberry Pi

Project description

DHT11 Python library

This simple class can be used for reading temperature and humidity values from DHT11 sensor on Raspberry Pi.

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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dht11-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

dht11-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file dht11-0.1.0.tar.gz.

File metadata

  • Download URL: dht11-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for dht11-0.1.0.tar.gz
Algorithm Hash digest
SHA256 148de58f2555ca05b85b0b3fadb2fcf8070ec7195daade4cb355685265a933c2
MD5 525d9d9f7831a6596775f0cafef1ad3a
BLAKE2b-256 f7f9cda6ad954c223849271c2fdf280eec921d2ef377bc90dc41e33e84dc8cb4

See more details on using hashes here.

File details

Details for the file dht11-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dht11-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for dht11-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69d1314322d409a0de7eff6df2896e98ae8f8274a597416e75dd1e7e2c2d23d9
MD5 aa4b708339b4db523738a352f833033e
BLAKE2b-256 64a15782c51fa87f641e50017ec10418435784ba7d75f5ea2e113317071d1ddf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page