8static const char *
const TAG =
"tee501";
11 ESP_LOGCONFIG(TAG,
"Running setup");
12 uint8_t
address[] = {0x70, 0x29};
13 this->
write(address, 2,
false);
14 uint8_t identification[9];
15 this->
read(identification, 9);
16 if (identification[8] !=
calc_crc8_(identification, 0, 7)) {
21 ESP_LOGV(TAG,
" Serial Number: 0x%s",
format_hex(identification + 0, 7).c_str());
25 ESP_LOGCONFIG(TAG,
"TEE501:");
27 switch (this->error_code_) {
29 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
32 ESP_LOGE(TAG,
"The crc check failed");
38 LOG_UPDATE_INTERVAL(
this);
39 LOG_SENSOR(
" ",
"TEE501",
this);
44 uint8_t address_1[] = {0x2C, 0x1B};
45 this->
write(address_1, 2,
true);
47 uint8_t i2c_response[3];
48 this->
read(i2c_response, 3);
49 if (i2c_response[2] !=
calc_crc8_(i2c_response, 0, 1)) {
60 ESP_LOGD(TAG,
"Got temperature=%.2f°C",
temperature);
67 unsigned char crc_val = 0xFF;
70 for (i = from; i <= to; i++) {
72 for (j = 0; j < 8; j++) {
73 if (((crc_val ^ cur_val) & 0x80) != 0)
75 crc_val = ((crc_val << 1) ^ 0x31);
77 crc_val = (crc_val << 1);
79 cur_val = cur_val << 1;
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
void publish_state(float state)
Publish a new state to the front-end.
enum esphome::tee501::TEE501Component::ErrorCode NONE
void dump_config() override
unsigned char calc_crc8_(const unsigned char buf[], unsigned char from, unsigned char to)
float get_setup_priority() const override
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.
std::string format_hex(const uint8_t *data, size_t length)
Format the byte array data of length len in lowercased hex.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.