ESPHome  2022.6.2
max31865.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace max31865 {
9 
20 };
24 };
25 
27  public PollingComponent,
28  public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
29  spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_4MHZ> {
30  public:
31  void set_reference_resistance(float reference_resistance) { reference_resistance_ = reference_resistance; }
32  void set_nominal_resistance(float nominal_resistance) { rtd_nominal_resistance_ = nominal_resistance; }
33  void set_filter(MAX31865ConfigFilter filter) { filter_ = filter; }
34  void set_num_rtd_wires(uint8_t rtd_wires) { rtd_wires_ = rtd_wires; }
35  void setup() override;
36  void dump_config() override;
37  float get_setup_priority() const override;
38 
39  void update() override;
40 
41  protected:
45  uint8_t rtd_wires_;
46  uint8_t base_config_;
47  bool has_fault_ = false;
48  bool has_warn_ = false;
49  void read_data_();
50  void write_config_(uint8_t mask, uint8_t bits, uint8_t start_position = 0);
51  void write_register_(uint8_t reg, uint8_t value);
52  uint8_t read_register_(uint8_t reg);
53  uint16_t read_register_16_(uint8_t reg);
54  float calc_temperature_(float rtd_ratio);
55 };
56 
57 } // namespace max31865
58 } // namespace esphome
uint16_t read_register_16_(uint8_t reg)
Definition: max31865.cpp:176
void set_filter(MAX31865ConfigFilter filter)
Definition: max31865.h:33
float get_setup_priority() const override
Definition: max31865.cpp:90
This class simplifies creating components that periodically check a state.
Definition: component.h:266
void set_reference_resistance(float reference_resistance)
Definition: max31865.h:31
void write_register_(uint8_t reg, uint8_t value)
Definition: max31865.cpp:159
float calc_temperature_(float rtd_ratio)
Definition: max31865.cpp:187
void write_config_(uint8_t mask, uint8_t bits, uint8_t start_position=0)
Definition: max31865.cpp:150
MAX31865ConfigFilter filter_
Definition: max31865.h:44
uint8_t read_register_(uint8_t reg)
Definition: max31865.cpp:167
Definition: a4988.cpp:4
void set_num_rtd_wires(uint8_t rtd_wires)
Definition: max31865.h:34
void set_nominal_resistance(float nominal_resistance)
Definition: max31865.h:32
Base-class for all sensors.
Definition: sensor.h:47