9static constexpr uint32_t CONVERSION_TIMEOUT_ID = 0;
11static constexpr uint8_t MAX31888_COMMAND_START_CONVERSION = 0x44;
12static constexpr uint8_t MAX31888_COMMAND_READ = 0x33;
13static constexpr uint8_t MAX31888_COMMAND_SOFT_RESET = 0x82;
14static constexpr uint8_t MAX31888_REGISTER_FIFO_DATA = 0x08;
15static constexpr uint8_t MAX31888_FIFO_READ_LENGTH = 0x01;
16static constexpr uint16_t MAX31888_CONVERSION_TIME_MS = 20;
17static constexpr float MAX31888_DEGREES_PER_LSB = 0.005f;
44 ESP_LOGCONFIG(TAG,
"MAX31888 Sensor:");
46 ESP_LOGW(TAG,
" Unable to select an address");
49 LOG_ONE_WIRE_DEVICE(
this);
50 LOG_UPDATE_INTERVAL(
this);
62 this->
set_timeout(CONVERSION_TIMEOUT_ID, MAX31888_CONVERSION_TIME_MS, [
this] {
77 uint8_t frame[7] = {MAX31888_COMMAND_READ, MAX31888_REGISTER_FIFO_DATA, MAX31888_FIFO_READ_LENGTH};
84 for (
size_t i = 3; i <
sizeof(frame); i++) {
void mark_failed()
Mark this component as failed.
void status_set_warning()
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
void status_clear_warning()
const StringRef & get_name() const
void dump_config() override
bool read_temperature_(int16_t &raw)
Reads the latest conversion from the FIFO; false when the bus or the checksum fails.
bool send_checked_command_(uint8_t command)
virtual void write8(uint8_t val)=0
Write a word to the bus. LSB first.
virtual uint8_t read8()=0
Read an 8 bit word from the bus.
OneWireBus * bus_
pointer to OneWireBus instance
bool send_command_(uint8_t cmd)
send command on the bus
bool check_address_or_index_()
find an address if necessary should be called from setup
void publish_state(float state)
Publish a new state to the front-end.
ESPHOME_LOG_TAG(TAG, "max31888")
uint16_t crc16(const uint8_t *data, uint16_t len, uint16_t crc, uint16_t reverse_poly, bool refin, bool refout)
Calculate a CRC-16 checksum of data with size len.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.