Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Simplifies reading temperature and humidity data from a DHT11/22 sensor using pigpio

Project description


Simplifies reading temperature and humidity data from a DHT11/22 sensor using pigpio


pip install pigpio


pip install dhtsensor


# Create a new Sensor object for a DHT22 temperature and humidity sensor
# GPIO to read from: 21
# GPIO that powers the sensor: 20
from dhtsensor.sensor import Sensor
s = Sensor(pi, 21, powered_by=20)

# Turn on power to the sensor

# Get temperature and humidity measurement from the sensor
# Do not call read_once repeatedly! Use .read instead
reading = s.read_once()

# Temperature and humidity as separate variables
temp, rh = s.read_once()

# Read from the sensor 10 times, with a 5-second interval between reads
# Outputs a list of 10 Reading objects
reading =, interval=5)


pigpio Python examples


License: 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.

Files for dhtsensor, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size dhtsensor-0.2.0.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page