idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
DHT Component

Type-safe DHT11/DHT22 (AM2302) sensor driver for ESP32. More...

Namespaces

namespace  idfxx
 
namespace  idfxx::dht
 DHT sensor classes and utilities.
 

Classes

struct  idfxx::dht::reading
 One temperature and humidity measurement. More...
 
class  idfxx::dht::sensor
 DHT11/DHT22 sensor on a single GPIO data line. More...
 

Enumerations

enum class  idfxx::dht::model : uint8_t {
  idfxx::dht::model::dht11 ,
  idfxx::dht::model::dht22
}
 Supported sensor models. More...
 

Detailed Description

Type-safe DHT11/DHT22 (AM2302) sensor driver for ESP32.

Reads temperature and relative humidity over the sensor's single-wire protocol. The host issues a start pulse on the data line and the sensor replies with a 40-bit frame, which is captured with the RMT peripheral (no interrupt-latency-sensitive bit-banging) and decoded with checksum verification.

Depends on Core Utilities for error handling and GPIO Component for pin configuration.

Enumeration Type Documentation

◆ model

enum class idfxx::dht::model : uint8_t
strong

Supported sensor models.

Selects the start-pulse timing and the 40-bit frame encoding. The AM2301 (DHT21) and AM2302 modules speak the DHT22 protocol.

Enumerator
dht11 

DHT11: 1 °C / 1 RH resolution, 1 s minimum sampling period.

dht22 

DHT22 / AM2301 / AM2302: 0.1 °C / 0.1 RH resolution, 2 s period.

Definition at line 48 of file dht.hpp.