ESPHome  2022.8.0
ads1115.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 namespace esphome {
9 namespace ads1115 {
10 
20 };
21 
29 };
30 
31 class ADS1115Sensor;
32 
33 class ADS1115Component : public Component, public i2c::I2CDevice {
34  public:
35  void register_sensor(ADS1115Sensor *obj) { this->sensors_.push_back(obj); }
37  void setup() override;
38  void dump_config() override;
40  float get_setup_priority() const override { return setup_priority::DATA; }
41  void set_continuous_mode(bool continuous_mode) { continuous_mode_ = continuous_mode; }
42 
44  float request_measurement(ADS1115Sensor *sensor);
45 
46  protected:
47  std::vector<ADS1115Sensor *> sensors_;
48  uint16_t prev_config_{0};
50 };
51 
54  public:
55  ADS1115Sensor(ADS1115Component *parent) : parent_(parent) {}
56  void update() override;
57  void set_multiplexer(ADS1115Multiplexer multiplexer) { multiplexer_ = multiplexer; }
58  void set_gain(ADS1115Gain gain) { gain_ = gain; }
59 
60  float sample() override;
61  uint8_t get_multiplexer() const { return multiplexer_; }
62  uint8_t get_gain() const { return gain_; }
63 
64  protected:
68 };
69 
70 } // namespace ads1115
71 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:18
uint8_t get_multiplexer() const
Definition: ads1115.h:61
float request_measurement(ADS1115Sensor *sensor)
Helper method to request a measurement from a sensor.
Definition: ads1115.cpp:82
Abstract interface for components to request voltage (usually ADC readings)
This class simplifies creating components that periodically check a state.
Definition: component.h:266
Internal holder class that is in instance of Sensor so that the hub can create individual sensors...
Definition: ads1115.h:53
void set_continuous_mode(bool continuous_mode)
Definition: ads1115.h:41
ADS1115Multiplexer multiplexer_
Definition: ads1115.h:66
ADS1115Sensor(ADS1115Component *parent)
Definition: ads1115.h:55
ADS1115Component * parent_
Definition: ads1115.h:65
uint8_t get_gain() const
Definition: ads1115.h:62
void set_gain(ADS1115Gain gain)
Definition: ads1115.h:58
std::vector< ADS1115Sensor * > sensors_
Definition: ads1115.h:47
void setup() override
Set up the internal sensor array.
Definition: ads1115.cpp:14
float get_setup_priority() const override
HARDWARE_LATE setup priority.
Definition: ads1115.h:40
void set_multiplexer(ADS1115Multiplexer multiplexer)
Definition: ads1115.h:57
Definition: a4988.cpp:4
Base-class for all sensors.
Definition: sensor.h:48
void register_sensor(ADS1115Sensor *obj)
Definition: ads1115.h:35