8static const char *
const TAG =
"iaqcore";
12static constexpr size_t SENSOR_DATA_LENGTH = 9;
20 SensorData(
const uint8_t *buffer) {
23 this->resistance =
encode_uint32(buffer[3], buffer[4], buffer[5], buffer[6]);
30 ESP_LOGD(TAG, ESP_LOG_MSG_COMM_FAIL);
37 uint8_t buffer[SENSOR_DATA_LENGTH];
40 ESP_LOGD(TAG,
"Read failed");
46 SensorData data(buffer);
48 switch (data.status) {
53 ESP_LOGI(TAG,
"Warming up");
56 ESP_LOGI(TAG,
"Busy");
59 ESP_LOGE(TAG,
"Error");
69 if (this->
co2_ !=
nullptr) {
72 if (this->
tvoc_ !=
nullptr) {
80 if (this->
co2_ !=
nullptr) {
83 if (this->
tvoc_ !=
nullptr) {
89 ESP_LOGCONFIG(TAG,
"AMS iAQ Core:");
91 LOG_UPDATE_INTERVAL(
this);
93 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
95 LOG_SENSOR(
" ",
"CO2", this->
co2_);
96 LOG_SENSOR(
" ",
"TVOC", this->
tvoc_);
void mark_failed()
Mark this component as failed.
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
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
@ ERROR_OK
No error found during execution of method.
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.