Skip to main content

Python implementation for Adafruit_DHT sensor for Raspberry Pi.

RPi.DHT is using DHT sensor with Raspberry Pi GPIO.

To connect to Raspberry Pi plug DHT sensor data into GPIO PIN 9 (Physical pin 21) and GROUD and POWER PINs. Install and execute RPi.DHT and it should work. Alternatively you can user different PIN and execute raspi-dht with parameter: raspi-dht --pin pin_number.

doc/RPi.DHT.png

RPi.DHT supports number of parameters and also configuration file. For more details see raspi-dht --help or sample config.

Sensor is based on RPi.Sensor library, which make base for implementing different types of sensors in Python.

There is an Ansible role at galaxy, which will do all the dependencies, config creation, and creates systemd service. Otherwise follow install instructions below…

Pre-Installation requirements

  • Update system and install required dependencies:

    sudo apt-get update

RPi.DHT needs Adafruit Python DHT Sensor Library. Make sure your system is able to compile Python extensions. On Raspbian or Debian/Ubuntu image you can ensure your system is ready by executing:

sudo apt-get install build-essential python3-dev python3-pip

Installation

  • Install the latest released version using pip:

    pip install https://github.com/ricco386/RPi.DHT/tarball/master/
  • Alternatively install latest released version from pypi:

    pip install --upgrade RPi.DHT

Integration as a systemd service

  • Make sure all dependencies (listed below) are installed (done automatically when installing via pip)

  • The raspi-dht command should be installed somewhere in your PATH (done automatically when installing via pip), make sure raspi-dht.service has corect path in ExecStart set to raspi-dht executable.

  • Systemd scripts are available: https://github.com/ricco386/RPi.DHT/tree/master/init.d to install them you will need root privileges, so we execute them as sudo:

    sudo cp init.d/raspi-dht.conf /etc/tmpfiles.d/
    sudo cp init.d/raspi-dht.service /etc/systemd/system/
    sudo systemd-tmpfiles --create /etc/tmpfiles.d/raspi-dht.conf
    sudo systemctl enable raspi-dht.service  # Enable service to start at system boot
    sudo systemctl start raspi-dht.service  # Start

Systemd scripts should be run under default Raspberry Pi user (pi), scripts have to be able access GPIO.

Dependencies:

Usage

You have to create a .sensor.cfg file and place into /home/pi/.sensor.cfg you can find example file in RPi.Sensor repo: https://github.com/ricco386/RPi.Sensor/blob/master/raspi_sensor/sensor.cfg.example and create section [DHT] where you can override default values.

raspi-dht also support multiple parameters to overwrite config parameters. For more info run:

raspi-dht --help

License

For more information see the LICENSE file.

Metadata

Release files for RPi.DHT 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RPi.DHT 0.5.0
File Size Uploaded
RPi.DHT-0.5.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for RPi.DHT 0.5.0
File Interpreter ABI Platform
RPi.DHT-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / RPi.DHT-0.5.0.tar.gz

Download URL RPi.DHT-0.5.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ac13011d04f28bcc57599685fa036446ec2d06e98b2fe55999e1bee21f8b69a8
BLAKE2b-256 checksum
How to use checksums
6501fac069d50af0f5199b66043a4a2e2ab02815712d86f37ec431560b00a6c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release files / RPi.DHT-0.5.0-py3-none-any.whl

Download URL RPi.DHT-0.5.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cac33cb2fd9cb6259112f092163cd202c89df811e399fa7412593f4ac80f1d8
BLAKE2b-256 checksum
How to use checksums
aa1c23e4df6bd2f77d264c8c0a9c9ca2adc74fa432f4281246cbb84575497b6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page