7 static const char *
const TAG =
"tmp1075";
17 static uint16_t temp2regvalue(
float temp);
18 static float regvalue2temp(uint16_t regvalue);
22 if (!this->
read_byte(REG_DIEID, &die_id)) {
23 ESP_LOGW(TAG,
"'%s' - unable to read ID", this->
name_.
c_str());
27 if (die_id != EXPECT_DIEID) {
28 ESP_LOGW(TAG,
"'%s' - unexpected ID 0x%x found, expected 0x%x", this->
name_.
c_str(), die_id,
EXPECT_DIEID);
39 ESP_LOGW(TAG,
"'%s' - unable to read temperature register", this->
name_.
c_str());
44 const float temp = regvalue2temp(regvalue);
49 LOG_SENSOR(
"",
"TMP1075 Sensor",
this);
51 ESP_LOGE(TAG,
" Communication with TMP1075 failed!");
58 ESP_LOGCONFIG(TAG,
" fault_count: %d",
config_.
fields.faults);
59 ESP_LOGCONFIG(TAG,
" polarity : %d",
config_.
fields.polarity);
60 ESP_LOGCONFIG(TAG,
" alert_mode : %d",
config_.
fields.alert_mode);
61 ESP_LOGCONFIG(TAG,
" shutdown : %d",
config_.
fields.shutdown);
66 ESP_LOGE(TAG,
"'%s' - fault_count too low: %d", this->
name_.
c_str(), faults);
70 ESP_LOGE(TAG,
"'%s' - fault_count too high: %d", this->
name_.
c_str(), faults);
95 ESP_LOGW(TAG,
"'%s' - unable to write configuration register", this->
name_.
c_str());
104 ESP_LOGW(TAG,
"'%s' - unable to write low limit register", this->
name_.
c_str());
113 ESP_LOGW(TAG,
"'%s' - unable to write high limit register", this->
name_.
c_str());
118 static uint16_t temp2regvalue(
const float temp) {
119 const uint16_t regvalue = temp / 0.0625f;
120 return regvalue << 4;
123 static float regvalue2temp(
const uint16_t regvalue) {
124 const int16_t signed_value = regvalue;
125 return (signed_value >> 4) * 0.0625f;
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
bool read_byte_16(uint8_t a_register, uint16_t *data)
void status_set_warning(const char *message="unspecified")
constexpr uint8_t REG_LLIM
void send_alert_limit_high_()
constexpr uint8_t REG_TEMP
struct esphome::tmp1075::TMP1075Config::@134::@136 fields
constexpr uint8_t REG_DIEID
void set_fault_count(int faults)
constexpr uint8_t REG_CFGR
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
constexpr uint16_t EXPECT_DIEID
constexpr const char * c_str() const
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
bool write_byte_16(uint8_t a_register, uint16_t data)
constexpr uint8_t REG_HLIM
void send_alert_limit_low_()