ESPHome  2022.12.8
dallas_component.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "esp_one_wire.h"
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace dallas {
11 
12 class DallasTemperatureSensor;
13 
15  public:
16  void set_pin(InternalGPIOPin *pin) { pin_ = pin; }
18 
19  void setup() override;
20  void dump_config() override;
21  float get_setup_priority() const override { return setup_priority::DATA; }
22 
23  void update() override;
24 
25  protected:
27 
30  std::vector<DallasTemperatureSensor *> sensors_;
31  std::vector<uint64_t> found_sensors_;
32 };
33 
36  public:
37  void set_parent(DallasComponent *parent) { parent_ = parent; }
39  uint8_t *get_address8();
41  const std::string &get_address_name();
42 
44  void set_address(uint64_t address);
46  optional<uint8_t> get_index() const;
48  void set_index(uint8_t index);
50  uint8_t get_resolution() const;
52  void set_resolution(uint8_t resolution);
54  uint16_t millis_to_wait_for_conversion() const;
55 
56  bool setup_sensor();
57  bool read_scratch_pad();
58 
59  bool check_scratch_pad();
60 
61  float get_temp_c();
62 
63  std::string unique_id() override;
64 
65  protected:
67  uint64_t address_;
69 
70  uint8_t resolution_;
71  std::string address_name_;
72  uint8_t scratch_pad_[9] = {
73  0,
74  };
75 };
76 
77 } // namespace dallas
78 } // namespace esphome
std::vector< DallasTemperatureSensor * > sensors_
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:18
float get_setup_priority() const override
Internal class that helps us create multiple sensors for one Dallas hub.
std::vector< uint64_t > found_sensors_
This class simplifies creating components that periodically check a state.
Definition: component.h:267
void set_parent(DallasComponent *parent)
void set_pin(InternalGPIOPin *pin)
void register_sensor(DallasTemperatureSensor *sensor)
Definition: a4988.cpp:4
Base-class for all sensors.
Definition: sensor.h:50