12static constexpr size_t SENSOR_DATA_LENGTH = 9;
20 SensorData(
const uint8_t *
buffer) {
35void IAQCore::update() {
36 uint8_t
buffer[SENSOR_DATA_LENGTH];
39 ESP_LOGD(TAG,
"Read failed");
47 switch (
data.status) {
52 ESP_LOGI(TAG,
"Warming up");
55 ESP_LOGI(TAG,
"Busy");
58 ESP_LOGE(TAG,
"Error");
68 PUBLISH_STATE(this->co2_sensor_,
data.co2);
69 PUBLISH_STATE(this->tvoc_sensor_,
data.tvoc);
75 PUBLISH_STATE(this->co2_sensor_, NAN);
76 PUBLISH_STATE(this->tvoc_sensor_, NAN);
79void IAQCore::dump_config() {
80 ESP_LOGCONFIG(TAG,
"AMS iAQ Core:");
82 LOG_UPDATE_INTERVAL(
this);
83 LOG_SENSOR(
" ",
"CO2", this->co2_sensor_);
84 LOG_SENSOR(
" ",
"TVOC", this->tvoc_sensor_);
void mark_failed()
Mark this component as failed.
virtual void setup()
Where the component's initialization should happen.
void status_set_warning()
void status_clear_warning()
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
@ ERROR_OK
No error found during execution of method.
ESPHOME_LOG_TAG(TAG, "iaqcore")
std::span< const uint8_t > data
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.