ESPHome  2024.12.2
ina3221.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace ina3221 {
9 
11  public:
12  void setup() override;
13  void dump_config() override;
14  void update() override;
15  float get_setup_priority() const override;
16 
17  void set_bus_voltage_sensor(int channel, sensor::Sensor *obj) { this->channels_[channel].bus_voltage_sensor_ = obj; }
18  void set_shunt_voltage_sensor(int channel, sensor::Sensor *obj) {
19  this->channels_[channel].shunt_voltage_sensor_ = obj;
20  }
21  void set_current_sensor(int channel, sensor::Sensor *obj) { this->channels_[channel].current_sensor_ = obj; }
22  void set_power_sensor(int channel, sensor::Sensor *obj) { this->channels_[channel].power_sensor_ = obj; }
23  void set_shunt_resistance(int channel, float resistance_ohm);
24 
25  protected:
26  struct INA3221Channel {
27  float shunt_resistance_{0.1f};
32 
33  bool exists();
36  } channels_[3];
37 };
38 
39 } // namespace ina3221
40 } // namespace esphome
void set_shunt_voltage_sensor(int channel, sensor::Sensor *obj)
Definition: ina3221.h:18
float get_setup_priority() const override
Definition: ina3221.cpp:117
void set_current_sensor(int channel, sensor::Sensor *obj)
Definition: ina3221.h:21
void set_power_sensor(int channel, sensor::Sensor *obj)
Definition: ina3221.h:22
This class simplifies creating components that periodically check a state.
Definition: component.h:283
struct esphome::ina3221::INA3221Component::INA3221Channel channels_[3]
void set_bus_voltage_sensor(int channel, sensor::Sensor *obj)
Definition: ina3221.h:17
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_shunt_resistance(int channel, float resistance_ohm)
Definition: ina3221.cpp:118
Base-class for all sensors.
Definition: sensor.h:57
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133