ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
max31856.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <cinttypes>
8
9namespace esphome::max31856 {
10
12
49
54 MAX31856_TCTYPE_B = 0b0000, // 0x00
55 MAX31856_TCTYPE_E = 0b0001, // 0x01
56 MAX31856_TCTYPE_J = 0b0010, // 0x02
57 MAX31856_TCTYPE_K = 0b0011, // 0x03
58 MAX31856_TCTYPE_N = 0b0100, // 0x04
59 MAX31856_TCTYPE_R = 0b0101, // 0x05
60 MAX31856_TCTYPE_S = 0b0110, // 0x06
61 MAX31856_TCTYPE_T = 0b0111, // 0x07
62 MAX31856_VMODE_G8 = 0b1000, // 0x08
63 MAX31856_VMODE_G32 = 0b1100, // 0x12
64};
65
70
72 public PollingComponent,
73 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
74 spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_4MHZ> {
75 public:
76 void setup() override;
77 void dump_config() override;
78 void set_filter(MAX31856ConfigFilter filter) { this->filter_ = filter; }
80 this->thermocouple_type_ = thermocouple_type;
81 }
82 void update() override;
83
84 protected:
87
88 uint8_t read_register_(uint8_t reg);
89 uint32_t read_register24_(uint8_t reg);
90 void write_register_(uint8_t reg, uint8_t value);
91
93 bool has_fault_();
94 void clear_fault_();
97 void set_noise_filter_();
98};
99
100} // namespace esphome::max31856
This class simplifies creating components that periodically check a state.
Definition component.h:585
void write_register_(uint8_t reg, uint8_t value)
Definition max31856.cpp:157
MAX31856ConfigFilter filter_
Definition max31856.h:85
MAX31856ThermocoupleType thermocouple_type_
Definition max31856.h:86
uint32_t read_register24_(uint8_t reg)
Definition max31856.cpp:182
uint8_t read_register_(uint8_t reg)
Definition max31856.cpp:170
void set_thermocouple_type(MAX31856ThermocoupleType thermocouple_type)
Definition max31856.h:79
void set_filter(MAX31856ConfigFilter filter)
Definition max31856.h:78
Base-class for all sensors.
Definition sensor.h:47
The SPIDevice is what components using the SPI will create.
Definition spi.h:429
MAX31856ThermocoupleType
Multiple types of thermocouples supported by the chip.
Definition max31856.h:53
@ MAX31856_CR0_1SHOT
Config 0 one shot convert flag.
Definition max31856.h:16
@ MAX31856_CR0_CJ
Config 0 cold junction disable flag.
Definition max31856.h:20
@ MAX31856_CR1_REG
Config 1 register.
Definition max31856.h:24
@ MAX31856_CR0_OCFAULT00
Config 0 open circuit fault 00 flag.
Definition max31856.h:17
@ MAX31856_CR0_OCFAULT10
Config 0 open circuit fault 10 flag.
Definition max31856.h:19
@ MAX31856_FAULT_TCLOW
Fault status Thermocouple Temperature Low Fault flag.
Definition max31856.h:45
@ MAX31856_CR0_FAULT
Config 0 fault mode flag.
Definition max31856.h:21
@ MAX31856_LTLFTH_REG
Linearized Temperature Low Fault Threshold Register, MSB.
Definition max31856.h:30
@ MAX31856_LTCBM_REG
Linearized TC Temperature, Byte 1.
Definition max31856.h:36
@ MAX31856_LTCBH_REG
Linearized TC Temperature, Byte 2.
Definition max31856.h:35
@ MAX31856_LTCBL_REG
Linearized TC Temperature, Byte 0.
Definition max31856.h:37
@ MAX31856_LTHFTH_REG
Linearized Temperature High Fault Threshold Register, MSB.
Definition max31856.h:28
@ MAX31856_CR0_AUTOCONVERT
Config 0 Auto convert flag.
Definition max31856.h:15
@ MAX31856_LTLFTL_REG
Linearized Temperature Low Fault Threshold Register, LSB.
Definition max31856.h:31
@ MAX31856_FAULT_TCRANGE
Fault status Thermocouple Out-of-Range flag.
Definition max31856.h:41
@ MAX31856_CJLF_REG
Cold junction Low temp fault register.
Definition max31856.h:27
@ MAX31856_CJHF_REG
Cold junction High temp fault register.
Definition max31856.h:26
@ MAX31856_CR0_REG
Config 0 register.
Definition max31856.h:14
@ MAX31856_CJTO_REG
Cold-Junction Temperature Offset Register.
Definition max31856.h:32
@ MAX31856_FAULT_OPEN
Fault status Thermocouple Open-Circuit Fault flag.
Definition max31856.h:47
@ MAX31856_FAULT_CJHIGH
Fault status Cold-Junction High Fault flag.
Definition max31856.h:42
@ MAX31856_CJTH_REG
Cold-Junction Temperature Register, MSB.
Definition max31856.h:33
@ MAX31856_LTHFTL_REG
Linearized Temperature High Fault Threshold Register, LSB.
Definition max31856.h:29
@ MAX31856_CJTL_REG
Cold-Junction Temperature Register, LSB.
Definition max31856.h:34
@ MAX31856_SR_REG
Fault Status Register.
Definition max31856.h:38
@ MAX31856_MASK_REG
Fault Mask register.
Definition max31856.h:25
@ MAX31856_FAULT_CJLOW
Fault status Cold-Junction Low Fault flag.
Definition max31856.h:43
@ MAX31856_FAULT_OVUV
Fault status Overvoltage or Undervoltage Input Fault flag.
Definition max31856.h:46
@ MAX31856_CR0_OCFAULT01
Config 0 open circuit fault 01 flag.
Definition max31856.h:18
@ MAX31856_FAULT_TCHIGH
Fault status Thermocouple Temperature High Fault flag.
Definition max31856.h:44
@ MAX31856_FAULT_CJRANGE
Fault status Cold Junction Out-of-Range flag.
Definition max31856.h:40
@ MAX31856_CR0_FAULTCLR
Config 0 fault clear flag.
Definition max31856.h:22
static void uint32_t