8 static const char *
const TAG =
"max31855";
22 ESP_LOGCONFIG(TAG,
"Setting up MAX31855Sensor '%s'...", this->
name_.
c_str());
26 ESP_LOGCONFIG(TAG,
"MAX31855:");
27 LOG_PIN(
" CS Pin: ", this->
cs_);
28 LOG_UPDATE_INTERVAL(
this);
29 LOG_SENSOR(
" ",
"Thermocouple",
this);
33 ESP_LOGCONFIG(TAG,
" Reference temperature disabled.");
44 const uint32_t mem =
encode_uint32(data[0], data[1], data[2], data[3]);
47 if (mem != 0xFFFFFFFF) {
50 ESP_LOGE(TAG,
"No data received from MAX31855 (0x%08" PRIX32
"). Check wiring!", mem);
61 int16_t
val = (mem & 0x0000FFF0) >> 4;
65 const float t_ref = float(val) * 0.0625f;
66 ESP_LOGD(TAG,
"Got reference temperature: %.4f°C", t_ref);
71 if (mem & 0x00000001) {
72 ESP_LOGW(TAG,
"Thermocouple open circuit (not connected) fault from MAX31855 (0x%08" PRIX32
")", mem);
77 if (mem & 0x00000002) {
78 ESP_LOGW(TAG,
"Thermocouple short circuit to ground fault from MAX31855 (0x%08" PRIX32
")", mem);
83 if (mem & 0x00000004) {
84 ESP_LOGW(TAG,
"Thermocouple short circuit to VCC fault from MAX31855 (0x%08" PRIX32
")", mem);
89 if (mem & 0x00010000) {
90 ESP_LOGW(TAG,
"Got faulty reading from MAX31855 (0x%08" PRIX32
")", mem);
97 int16_t
val = (mem & 0xFFFC0000) >> 18;
101 const float t_sense = float(val) * 0.25f;
102 ESP_LOGD(TAG,
"Got thermocouple temperature: %.2f°C", t_sense);
float get_setup_priority() const override
const float DATA
For components that import data from directly connected sensors like DHT.
void status_set_warning(const char *message="unspecified")
void spi_setup() override
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
void dump_config() override
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
sensor::Sensor * temperature_reference_
void status_set_error(const char *message="unspecified")
void read_array(uint8_t *data, size_t length)
void status_clear_warning()
void publish_state(float state)
Publish a new state to the front-end.
constexpr const char * c_str() const
void status_clear_error()
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delay(uint32_t ms)