ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
ina226.h
Go to the documentation of this file.
1#pragma once
6
7namespace esphome::ina226 {
8
19
30
32 uint16_t raw;
33 struct {
34 uint16_t mode : 3;
38 uint16_t reserved : 3;
39 uint16_t reset : 1;
40 } __attribute__((packed));
41};
42
43class INA226Component final : public PollingComponent, public i2c::I2CDevice {
44 SUB_SENSOR(bus_voltage)
45 SUB_SENSOR(shunt_voltage)
46 SUB_SENSOR(current)
47 SUB_SENSOR(power)
48
49 public:
50 void setup() override;
51 void dump_config() override;
52 void update() override;
53
54 void set_shunt_resistance_ohm(float shunt_resistance_ohm) { shunt_resistance_ohm_ = shunt_resistance_ohm; }
55 void set_max_current_a(float max_current_a) { max_current_a_ = max_current_a; }
56 void set_adc_time_voltage(AdcTime time) { adc_time_voltage_ = time; }
57 void set_adc_time_current(AdcTime time) { adc_time_current_ = time; }
58 void set_adc_avg_samples(AdcAvgSamples samples) { adc_avg_samples_ = samples; }
59
60 protected:
67};
68
69} // namespace esphome::ina226
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
AdcAvgSamples adc_avg_samples_
Definition ina226.h:65
struct @66::@67 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:45
@ ADC_AVG_SAMPLES_1
Definition ina226.h:21
@ ADC_AVG_SAMPLES_16
Definition ina226.h:23
@ ADC_AVG_SAMPLES_256
Definition ina226.h:26
@ ADC_AVG_SAMPLES_512
Definition ina226.h:27
@ ADC_AVG_SAMPLES_64
Definition ina226.h:24
@ ADC_AVG_SAMPLES_1024
Definition ina226.h:28
@ ADC_AVG_SAMPLES_128
Definition ina226.h:25
@ ADC_AVG_SAMPLES_4
Definition ina226.h:22
static void uint32_t