diff --git a/esphome/components/tmp1075/tmp1075.cpp b/esphome/components/tmp1075/tmp1075.cpp index 38ed2bea31..68253a11f1 100644 --- a/esphome/components/tmp1075/tmp1075.cpp +++ b/esphome/components/tmp1075/tmp1075.cpp @@ -18,14 +18,9 @@ static uint16_t temp2regvalue(float temp); static float regvalue2temp(uint16_t regvalue); void TMP1075Sensor::setup() { - uint8_t die_id; - if (!this->read_byte(REG_DIEID, &die_id)) { - ESP_LOGW(TAG, "'%s' - unable to read ID", this->name_.c_str()); - this->mark_failed(); - return; - } - if (die_id != EXPECT_DIEID) { - ESP_LOGW(TAG, "'%s' - unexpected ID 0x%x found, expected 0x%x", this->name_.c_str(), die_id, EXPECT_DIEID); + uint8_t cfg; + if (!this->read_byte(REG_CFGR, &cfg)) { + ESP_LOGE(TAG, "'%s' - unable to read", this->name_.c_str()); this->mark_failed(); return; } @@ -37,9 +32,10 @@ void TMP1075Sensor::update() { uint16_t regvalue; if (!read_byte_16(REG_TEMP, ®value)) { ESP_LOGW(TAG, "'%s' - unable to read temperature register", this->name_.c_str()); - this->status_set_warning(); + this->status_set_warning("can't read"); return; } + this->status_clear_warning(); const float temp = regvalue2temp(regvalue); this->publish_state(temp); @@ -89,9 +85,9 @@ void TMP1075Sensor::write_config() { } void TMP1075Sensor::send_config_() { - ESP_LOGV(TAG, "'%s' - sending configuration %04x", this->name_.c_str(), config_.regvalue); + ESP_LOGV(TAG, "'%s' - sending configuration %02x", this->name_.c_str(), config_.regvalue); log_config_(); - if (!this->write_byte_16(REG_CFGR, config_.regvalue)) { + if (!this->write_byte(REG_CFGR, config_.regvalue)) { ESP_LOGW(TAG, "'%s' - unable to write configuration register", this->name_.c_str()); return; } diff --git a/esphome/components/tmp1075/tmp1075.h b/esphome/components/tmp1075/tmp1075.h index db2bac517a..84e2e8abe4 100644 --- a/esphome/components/tmp1075/tmp1075.h +++ b/esphome/components/tmp1075/tmp1075.h @@ -36,9 +36,8 @@ struct TMP1075Config { uint8_t shutdown : 1; // Sets the device in shutdown mode to conserve power. // 0: Device is in continuous conversion // 1: Device is in shutdown mode - uint8_t unused : 8; } fields; - uint16_t regvalue; + uint8_t regvalue; }; };