mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
28 lines
788 B
C++
28 lines
788 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/sensor/sensor.h"
|
|
#include "esphome/components/i2c/i2c.h"
|
|
|
|
namespace esphome {
|
|
namespace dht12 {
|
|
|
|
class DHT12Component : public PollingComponent, public i2c::I2CDevice {
|
|
public:
|
|
void setup() override;
|
|
void dump_config() override;
|
|
float get_setup_priority() const override;
|
|
void update() override;
|
|
|
|
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
|
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
|
|
|
|
protected:
|
|
bool read_data_(uint8_t *data);
|
|
|
|
sensor::Sensor *temperature_sensor_{nullptr};
|
|
sensor::Sensor *humidity_sensor_{nullptr};
|
|
};
|
|
|
|
} // namespace dht12
|
|
} // namespace esphome
|