Documentation

DHT Extension

The DHT extension connects to a digital humidity temperature (DHT) device using CircuitPython to gather temperature and humidity readings.

Overview

The dht extension connects to a digital humidity temperature (DHT) device to gather temperature and humidity readings. Through the support of adafruit-circuitpython-dht you can use a large variety of supported Linux boards.

This is the recommended extension for DHT sensors. The older DHT Legacy extension is deprecated and will be removed in a future release.

This extension does not take an extension-level config and is focused on interfaces.

Sensor Interface

Provides a sensor that returns DHT readings.

Option Type Required Description
key String Yes Unique slug id for the component
pin String Yes GPIO pin to use on board, e.g. D12
name String No Friendly display name of component. Useful for UI.
model String No Model of DHT device to use. Options: 11, 22, or 2302. Default: 11
read_attempts Integer No Number of times to try and get a valid reading. Each read waits the recommended 2.1s between each attempt. Default: 3. Avoid locks and keep this under 5.

Config Example

Here is a config of a complete DHT sensor.

mudpi.config.json
{
  "sensor": [
    {
      "key": "dht_sensor_D12",
      "interface": "dht",
      "pin": "D12",
      "model": "22"
    }
  ]
}

Data

Here is an example of the data returned by the DHT:

DHT Sensor Data
{
  "temperature": 50,
  "humidity": 64
}

Note

DHT is a finicky sensor and it has been known to have high read fail rates. ARMv6 may experience issues with DHT more frequently.