ESPHome  2024.10.2
max31856.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <cinttypes>
8 
9 namespace esphome {
10 namespace max31856 {
11 
13 
21  MAX31856_CR0_CJ = 0x08,
24 
39  MAX31856_SR_REG = 0x0F,
40 
49 };
50 
55  MAX31856_TCTYPE_B = 0b0000, // 0x00
56  MAX31856_TCTYPE_E = 0b0001, // 0x01
57  MAX31856_TCTYPE_J = 0b0010, // 0x02
58  MAX31856_TCTYPE_K = 0b0011, // 0x03
59  MAX31856_TCTYPE_N = 0b0100, // 0x04
60  MAX31856_TCTYPE_R = 0b0101, // 0x05
61  MAX31856_TCTYPE_S = 0b0110, // 0x06
62  MAX31856_TCTYPE_T = 0b0111, // 0x07
63  MAX31856_VMODE_G8 = 0b1000, // 0x08
64  MAX31856_VMODE_G32 = 0b1100, // 0x12
65 };
66 
70 };
71 
73  public PollingComponent,
74  public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
75  spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_4MHZ> {
76  public:
77  void setup() override;
78  void dump_config() override;
79  float get_setup_priority() const override;
80  void set_filter(MAX31856ConfigFilter filter) { this->filter_ = filter; }
82  this->thermocouple_type_ = thermocouple_type;
83  }
84  void update() override;
85 
86  protected:
89 
90  uint8_t read_register_(uint8_t reg);
91  uint32_t read_register24_(uint8_t reg);
92  void write_register_(uint8_t reg, uint8_t value);
93 
94  void one_shot_temperature_();
95  bool has_fault_();
96  void clear_fault_();
99  void set_noise_filter_();
100 };
101 
102 } // namespace max31856
103 } // namespace esphome
Linearized TC Temperature, Byte 2.
Definition: max31856.h:36
MAX31856ConfigFilter filter_
Definition: max31856.h:87
Linearized TC Temperature, Byte 0.
Definition: max31856.h:38
Config 0 fault mode flag.
Definition: max31856.h:22
Config 0 one shot convert flag.
Definition: max31856.h:17
Fault status Cold Junction Out-of-Range flag.
Definition: max31856.h:41
Config 0 open circuit fault 01 flag.
Definition: max31856.h:19
Cold junction Low temp fault register.
Definition: max31856.h:28
Cold-Junction Temperature Register, LSB.
Definition: max31856.h:35
Fault status Overvoltage or Undervoltage Input Fault flag.
Definition: max31856.h:47
uint32_t read_register24_(uint8_t reg)
Definition: max31856.cpp:189
This class simplifies creating components that periodically check a state.
Definition: component.h:283
Config 0 cold junction disable flag.
Definition: max31856.h:21
Config 0 open circuit fault 00 flag.
Definition: max31856.h:18
Linearized Temperature Low Fault Threshold Register, LSB.
Definition: max31856.h:32
Config 0 open circuit fault 10 flag.
Definition: max31856.h:20
Fault status Thermocouple Temperature Low Fault flag.
Definition: max31856.h:46
MAX31856ThermocoupleType thermocouple_type_
Definition: max31856.h:88
The SPIDevice is what components using the SPI will create.
Definition: spi.h:391
void write_register_(uint8_t reg, uint8_t value)
Definition: max31856.cpp:164
Fault status Thermocouple Temperature High Fault flag.
Definition: max31856.h:45
Fault status Cold-Junction Low Fault flag.
Definition: max31856.h:44
MAX31856ThermocoupleType
Multiple types of thermocouples supported by the chip.
Definition: max31856.h:54
Fault Mask register.
Definition: max31856.h:26
Fault status Cold-Junction High Fault flag.
Definition: max31856.h:43
uint8_t read_register_(uint8_t reg)
Definition: max31856.cpp:177
Fault status Thermocouple Open-Circuit Fault flag.
Definition: max31856.h:48
Linearized TC Temperature, Byte 1.
Definition: max31856.h:37
Linearized Temperature High Fault Threshold Register, LSB.
Definition: max31856.h:30
Linearized Temperature Low Fault Threshold Register, MSB.
Definition: max31856.h:31
void set_filter(MAX31856ConfigFilter filter)
Definition: max31856.h:80
Config 0 Auto convert flag.
Definition: max31856.h:16
Fault Status Register.
Definition: max31856.h:39
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Config 0 fault clear flag.
Definition: max31856.h:23
Base-class for all sensors.
Definition: sensor.h:57
Cold-Junction Temperature Register, MSB.
Definition: max31856.h:34
Linearized Temperature High Fault Threshold Register, MSB.
Definition: max31856.h:29
Cold junction High temp fault register.
Definition: max31856.h:27
float get_setup_priority() const override
Definition: max31856.cpp:206
Fault status Thermocouple Out-of-Range flag.
Definition: max31856.h:42
void set_thermocouple_type(MAX31856ThermocoupleType thermocouple_type)
Definition: max31856.h:81
Cold-Junction Temperature Offset Register.
Definition: max31856.h:33