esphome/esphome/components/am2320/am2320.h
Teemu Mikkonen 3b48aa5911 Support for AM2320 temperature and humidity sensor (#554)
Support for AM2320 temperature and humidity sensor

Co-authored-by: Mikkonen Teemu <teemu.mikkonen@iki.fi>
2019-05-27 20:00:32 +02:00

29 lines
866 B
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace am2320 {
class AM2320Component : 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);
bool read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion = 0);
sensor::Sensor *temperature_sensor_;
sensor::Sensor *humidity_sensor_;
};
} // namespace am2320
} // namespace esphome