import dht
The dht module reads common single-wire DHT sensors and returns temperature and humidity data from firmware. It is useful for small environmental monitors.
Quick example
import dht reading = dht.read(4) reading = dht.read(4, "DHT22")
importdht
DHT temperature and humidity module.
The dht module reads common single-wire DHT sensors and returns temperature and humidity data from firmware. It is useful for small environmental monitors.
API
1 available
dht.read(pin: int, sensor_type: str = None) -> dict
dht.read(pin: int, sensor_type: str = None) -> dictRead temperature and humidity from a DHT sensor.
Parameters
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
pin |
int |
positional or keyword | Yes | GPIO pin connected to the DHT data line. |
sensor_type |
str |
positional or keyword | No | Optional native sensor type, such as "DHT11" or "DHT22". |
Returns
dict Native map-like value containing temperature and humidity fields.