ESPHome  2022.6.2
dht.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
6 
7 namespace esphome {
8 namespace dht {
9 
10 enum DHTModel {
18 };
19 
21 class DHT : public PollingComponent {
22  public:
37  void set_dht_model(DHTModel model);
38 
39  void set_pin(InternalGPIOPin *pin) { pin_ = pin; }
40  void set_model(DHTModel model) { model_ = model; }
41  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
42  void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
43 
45  void setup() override;
46  void dump_config() override;
48  void update() override;
50  float get_setup_priority() const override;
51 
52  protected:
53  bool read_sensor_(float *temperature, float *humidity, bool report_errors);
54 
57  bool is_auto_detect_{false};
60 };
61 
62 } // namespace dht
63 } // namespace esphome
sensor::Sensor * temperature_sensor_
Definition: dht.h:58
DHTModel model_
Definition: dht.h:56
void set_dht_model(DHTModel model)
Manually select the DHT model.
Definition: dht.cpp:70
InternalGPIOPin * pin_
Definition: dht.h:55
Component for reading temperature/humidity measurements from DHT11/DHT22 sensors. ...
Definition: dht.h:21
bool is_auto_detect_
Definition: dht.h:57
sensor::Sensor * humidity_sensor_
Definition: dht.h:59
float temperature
Definition: qmp6988.h:71
This class simplifies creating components that periodically check a state.
Definition: component.h:266
float get_setup_priority() const override
HARDWARE_LATE setup priority.
Definition: dht.cpp:69
void dump_config() override
Definition: dht.cpp:16
void set_humidity_sensor(sensor::Sensor *humidity_sensor)
Definition: dht.h:42
void set_model(DHTModel model)
Definition: dht.h:40
DHTModel
Definition: dht.h:10
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition: dht.h:41
bool read_sensor_(float *temperature, float *humidity, bool report_errors)
Definition: dht.cpp:74
void setup() override
Set up the pins and check connection.
Definition: dht.cpp:10
void update() override
Update sensor values and push them to the frontend.
Definition: dht.cpp:33
void set_pin(InternalGPIOPin *pin)
Definition: dht.h:39
Definition: a4988.cpp:4
Base-class for all sensors.
Definition: sensor.h:47