32#include <thermo/thermo>
88#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
137#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
179 explicit sensor(std::unique_ptr<state> s)
noexcept;
182 std::unique_ptr<state> _state;
205 return "unknown(" + std::to_string(std::to_underlying(m)) +
')';
211#include "sdkconfig.h"
212#ifdef CONFIG_IDFXX_STD_FORMAT
218struct formatter<
idfxx::dht::model> {
219 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
221 template<
typename FormatContext>
224 return std::copy(s.begin(), s.end(), ctx.out());
DHT11/DHT22 sensor on a single GPIO data line.
std::chrono::milliseconds min_read_interval() const noexcept
Returns the minimum interval between reads for the model.
idfxx::gpio pin() const noexcept
Returns the configured data-line GPIO.
sensor(config config)
Constructs a sensor driver.
result< reading > try_read()
Performs one measurement.
sensor & operator=(sensor &&other) noexcept
static result< sensor > make(config config)
Creates a sensor driver.
sensor(const sensor &)=delete
reading read()
Performs one measurement.
sensor(sensor &&other) noexcept
sensor & operator=(const sensor &)=delete
static constexpr gpio nc()
Returns a GPIO representing "not connected".
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
model
Supported sensor models.
@ 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.
DHT sensor classes and utilities.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
One temperature and humidity measurement.
float humidity_pct
Relative humidity in percent (0–100).
thermo::millicelsius temperature
Measured temperature.
Configuration for a DHT sensor.
idfxx::gpio pin
Data line GPIO (required).
bool internal_pullup
Enable the internal pull-up on the data line.