9 static const char *
const TAG =
"iaqcore";
19 SensorData(
const uint8_t *buffer) {
22 this->resistance =
encode_uint32(buffer[3], buffer[4], buffer[5], buffer[6]);
29 ESP_LOGD(TAG,
"Communication failed!");
36 uint8_t buffer[
sizeof(SensorData)];
38 if (this->read_register(0xB5, buffer,
sizeof(buffer),
false) !=
i2c::ERROR_OK) {
39 ESP_LOGD(TAG,
"Read failed");
40 this->status_set_warning();
41 this->publish_nans_();
45 SensorData data(buffer);
47 switch (data.status) {
52 ESP_LOGI(TAG,
"Warming up");
55 ESP_LOGI(TAG,
"Busy");
58 ESP_LOGE(TAG,
"Error");
63 this->status_set_warning();
64 this->publish_nans_();
68 if (this->co2_ !=
nullptr) {
69 this->co2_->publish_state(data.co2);
71 if (this->tvoc_ !=
nullptr) {
72 this->tvoc_->publish_state(data.tvoc);
75 this->status_clear_warning();
79 if (this->co2_ !=
nullptr) {
80 this->co2_->publish_state(NAN);
82 if (this->tvoc_ !=
nullptr) {
83 this->tvoc_->publish_state(NAN);
88 ESP_LOGCONFIG(TAG,
"AMS iAQ Core:");
90 LOG_UPDATE_INTERVAL(
this);
91 if (this->is_failed()) {
92 ESP_LOGE(TAG,
"Communication with AMS iAQ Core failed!");
94 LOG_SENSOR(
" ",
"CO2", this->co2_);
95 LOG_SENSOR(
" ",
"TVOC", this->tvoc_);
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.
void dump_config() override
No error found during execution of method.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
Implementation of SPI Controller mode.