ESPHome 2026.6.0-dev
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
44 public:
45 void setup() override;
46 void dump_config() override;
47 void update() override;
48
49 void set_shunt_resistance_ohm(float shunt_resistance_ohm) { shunt_resistance_ohm_ = shunt_resistance_ohm; }
50 void set_max_current_a(float max_current_a) { max_current_a_ = max_current_a; }
54
55 void set_bus_voltage_sensor(sensor::Sensor *bus_voltage_sensor) { bus_voltage_sensor_ = bus_voltage_sensor; }
56 void set_shunt_voltage_sensor(sensor::Sensor *shunt_voltage_sensor) { shunt_voltage_sensor_ = shunt_voltage_sensor; }
57 void set_current_sensor(sensor::Sensor *current_sensor) { current_sensor_ = current_sensor; }
58 void set_power_sensor(sensor::Sensor *power_sensor) { power_sensor_ = power_sensor; }
59
60 protected:
71
72 int32_t twos_complement_(int32_t val, uint8_t bits);
73};
74
75} // namespace esphome::ina226
This class simplifies creating components that periodically check a state.
Definition component.h:585
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
void set_adc_time_voltage(AdcTime time)
Definition ina226.h:51
void set_current_sensor(sensor::Sensor *current_sensor)
Definition ina226.h:57
void set_shunt_voltage_sensor(sensor::Sensor *shunt_voltage_sensor)
Definition ina226.h:56
void set_bus_voltage_sensor(sensor::Sensor *bus_voltage_sensor)
Definition ina226.h:55
void set_adc_avg_samples(AdcAvgSamples samples)
Definition ina226.h:53
sensor::Sensor * power_sensor_
Definition ina226.h:70
sensor::Sensor * bus_voltage_sensor_
Definition ina226.h:67
sensor::Sensor * current_sensor_
Definition ina226.h:69
void set_adc_time_current(AdcTime time)
Definition ina226.h:52
sensor::Sensor * shunt_voltage_sensor_
Definition ina226.h:68
AdcAvgSamples adc_avg_samples_
Definition ina226.h:65
void set_max_current_a(float max_current_a)
Definition ina226.h:50
int32_t twos_complement_(int32_t val, uint8_t bits)
Definition ina226.cpp:156
void set_power_sensor(sensor::Sensor *power_sensor)
Definition ina226.h:58
void set_shunt_resistance_ohm(float shunt_resistance_ohm)
Definition ina226.h:49
Base-class for all sensors.
Definition sensor.h:47
struct @65::@66 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:32
mopeka_std_values val[3]
@ 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