DHT11/DHT22 sensor on a single GPIO data line.
More...
DHT11/DHT22 sensor on a single GPIO data line.
Move-only. The destructor releases the RMT receive channel.
DHT11/DHT22 sensor on a single GPIO data line.
reading read()
Performs one measurement.
@ dht22
DHT22 / AM2301 / AM2302: 0.1 °C / 0.1 RH resolution, 2 s period.
Definition at line 74 of file dht.hpp.
◆ sensor() [1/3]
| idfxx::dht::sensor::sensor |
( |
config |
config | ) |
|
|
explicit |
Constructs a sensor driver.
Claims an RMT receive channel for the data line and configures the pin as an open-drain input/output.
- Parameters
-
| config | Sensor configuration. |
- Note
- Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
- Exceptions
-
| std::system_error | on failure (e.g. no free RMT channel). |
◆ ~sensor()
| idfxx::dht::sensor::~sensor |
( |
| ) |
|
◆ sensor() [2/3]
| idfxx::dht::sensor::sensor |
( |
const sensor & |
| ) |
|
|
delete |
◆ sensor() [3/3]
| idfxx::dht::sensor::sensor |
( |
sensor && |
other | ) |
|
|
noexcept |
◆ make()
Creates a sensor driver.
Claims an RMT receive channel for the data line and configures the pin as an open-drain input/output.
- Parameters
-
| config | Sensor configuration. |
- Returns
- The driver, or an error.
- Return values
-
◆ min_read_interval()
| std::chrono::milliseconds idfxx::dht::sensor::min_read_interval |
( |
| ) |
const |
|
noexcept |
Returns the minimum interval between reads for the model.
1 s for the DHT11, 2 s for the DHT22. try_read fails with idfxx::errc::invalid_state when called again sooner.
- Returns
- The model's minimum sampling period.
◆ model()
| enum model idfxx::dht::sensor::model |
( |
| ) |
const |
|
noexcept |
Returns the configured sensor model.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ pin()
Returns the configured data-line GPIO.
◆ read()
| reading idfxx::dht::sensor::read |
( |
| ) |
|
|
inline |
Performs one measurement.
Issues the start pulse, captures the sensor's 40-bit reply, verifies its checksum, and converts it. Blocks for the start pulse plus the reply: roughly 25 ms for the DHT11 (its ~20 ms start pulse dominates) and under 10 ms for the DHT22.
- Returns
- The measurement.
- Note
- Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
- Exceptions
-
| std::system_error | on failure; see try_read for the error conditions. |
Definition at line 151 of file dht.hpp.
References try_read(), and idfxx::unwrap().
◆ try_read()
Performs one measurement.
Issues the start pulse, captures the sensor's 40-bit reply, verifies its checksum, and converts it. Blocks for the start pulse plus the reply: roughly 25 ms for the DHT11 (its ~20 ms start pulse dominates) and under 10 ms for the DHT22.
- Returns
- The measurement, or an error.
- Return values
-
Referenced by read().
The documentation for this class was generated from the following file: