8static const uint8_t MCP9600_REGISTER_HOT_JUNCTION = 0x00;
10static const uint8_t MCP9600_REGISTER_COLD_JUNTION = 0x02;
12static const uint8_t MCP9600_REGISTER_STATUS = 0x04;
13static const uint8_t MCP9600_REGISTER_SENSOR_CONFIG = 0x05;
14static const uint8_t MCP9600_REGISTER_CONFIG = 0x06;
15static const uint8_t MCP9600_REGISTER_ALERT1_CONFIG = 0x08;
16static const uint8_t MCP9600_REGISTER_ALERT2_CONFIG = 0x09;
17static const uint8_t MCP9600_REGISTER_ALERT3_CONFIG = 0x0A;
18static const uint8_t MCP9600_REGISTER_ALERT4_CONFIG = 0x0B;
19static const uint8_t MCP9600_REGISTER_ALERT1_HYSTERESIS = 0x0C;
20static const uint8_t MCP9600_REGISTER_ALERT2_HYSTERESIS = 0x0D;
21static const uint8_t MCP9600_REGISTER_ALERT3_HYSTERESIS = 0x0E;
22static const uint8_t MCP9600_REGISTER_ALERT4_HYSTERESIS = 0x0F;
23static const uint8_t MCP9600_REGISTER_ALERT1_LIMIT = 0x10;
24static const uint8_t MCP9600_REGISTER_ALERT2_LIMIT = 0x11;
25static const uint8_t MCP9600_REGISTER_ALERT3_LIMIT = 0x12;
26static const uint8_t MCP9600_REGISTER_ALERT4_LIMIT = 0x13;
27static const uint8_t MCP9600_REGISTER_DEVICE_ID = 0x20;
36 this->
mark_failed(LOG_STR(
"Connected device does not match a known MCP9600 or MCP9601 sensor"));
40 bool success = this->
write_byte(MCP9600_REGISTER_STATUS, 0x00);
42 success &= this->
write_byte(MCP9600_REGISTER_CONFIG, 0x00);
43 success &= this->
write_byte(MCP9600_REGISTER_ALERT1_CONFIG, 0x00);
44 success &= this->
write_byte(MCP9600_REGISTER_ALERT2_CONFIG, 0x00);
45 success &= this->
write_byte(MCP9600_REGISTER_ALERT3_CONFIG, 0x00);
46 success &= this->
write_byte(MCP9600_REGISTER_ALERT4_CONFIG, 0x00);
47 success &= this->
write_byte(MCP9600_REGISTER_ALERT1_HYSTERESIS, 0x00);
48 success &= this->
write_byte(MCP9600_REGISTER_ALERT2_HYSTERESIS, 0x00);
49 success &= this->
write_byte(MCP9600_REGISTER_ALERT3_HYSTERESIS, 0x00);
50 success &= this->
write_byte(MCP9600_REGISTER_ALERT4_HYSTERESIS, 0x00);
51 success &= this->
write_byte_16(MCP9600_REGISTER_ALERT1_LIMIT, 0x0000);
52 success &= this->
write_byte_16(MCP9600_REGISTER_ALERT2_LIMIT, 0x0000);
53 success &= this->
write_byte_16(MCP9600_REGISTER_ALERT3_LIMIT, 0x0000);
54 success &= this->
write_byte_16(MCP9600_REGISTER_ALERT4_LIMIT, 0x0000);
57 this->
mark_failed(LOG_STR(
"Failed to update device configuration"));
62void MCP9600Component::dump_config() {
68 LOG_UPDATE_INTERVAL(
this);
69 LOG_SENSOR(
" ",
"Hot Junction Temperature", this->hot_junction_sensor_);
70 LOG_SENSOR(
" ",
"Cold Junction Temperature", this->cold_junction_sensor_);
73void MCP9600Component::update() {
74 if (this->hot_junction_sensor_ !=
nullptr) {
75 uint16_t raw_hot_junction_temperature;
76 if (!this->
read_byte_16(MCP9600_REGISTER_HOT_JUNCTION, &raw_hot_junction_temperature)) {
80 float hot_junction_temperature = int16_t(raw_hot_junction_temperature) * 0.0625;
81 this->hot_junction_sensor_->publish_state(hot_junction_temperature);
84 if (this->cold_junction_sensor_ !=
nullptr) {
85 uint16_t raw_cold_junction_temperature;
86 if (!this->
read_byte_16(MCP9600_REGISTER_COLD_JUNTION, &raw_cold_junction_temperature)) {
90 float cold_junction_temperature = int16_t(raw_cold_junction_temperature) * 0.0625;
91 this->cold_junction_sensor_->publish_state(cold_junction_temperature);