7 namespace ina2xx_base {
116 void setup()
override;
117 float get_setup_priority()
const override;
118 void update()
override;
119 void loop()
override;
120 void dump_config()
override;
143 bool reset_energy_counters();
146 bool reset_config_();
147 bool check_device_model_();
148 bool configure_adc_();
150 bool configure_shunt_();
151 bool configure_shunt_tempco_();
152 bool configure_adc_range_();
154 bool read_shunt_voltage_mv_(
float &volt_out);
155 bool read_bus_voltage_(
float &volt_out);
156 bool read_die_temp_c_(
float &temp);
157 bool read_current_a_(
float &s_out);
158 bool read_power_w_(
float &power_out);
159 bool read_energy_(
double &joules_out,
double &watt_hours_out);
160 bool read_charge_(
double &coulombs_out,
double &_hours_out);
162 bool read_diagnostics_and_act_();
174 uint16_t shunt_tempco_ppm_c_{0};
179 uint16_t shunt_cal_{0};
180 float current_lsb_{0};
182 uint32_t energy_overflows_count_{0};
183 uint32_t charge_overflows_count_{0};
202 NOT_INITIALIZED = 0x0,
212 } state_{State::NOT_INITIALIZED};
214 bool full_loop_is_okay_{
true};
221 bool device_mismatch_{
false};
240 bool read_unsigned_(uint8_t reg, uint8_t reg_size, uint64_t &data_out);
241 bool read_unsigned_16_(uint8_t reg, uint16_t &out);
242 bool write_unsigned_16_(uint8_t reg, uint16_t
val);
244 int64_t two_complement_(uint64_t value, uint8_t bits);
249 virtual bool read_ina_register(uint8_t a_register, uint8_t *data,
size_t len) = 0;
250 virtual bool write_ina_register(uint8_t a_register,
const uint8_t *data,
size_t len) = 0;
void set_model(INAModel model)
void set_charge_sensor_ah(sensor::Sensor *sensor)
void set_die_temperature_sensor(sensor::Sensor *sensor)
struct esphome::ina2xx_base::ConfigurationRegister::@83 __attribute__((packed))
This class simplifies creating components that periodically check a state.
void set_adc_time_shunt_voltage(AdcTime time)
void set_shunt_tempco(uint16_t coeff)
float shunt_resistance_ohm_
void set_adc_time_bus_voltage(AdcTime time)
void set_shunt_voltage_sensor(sensor::Sensor *sensor)
void set_adc_time_die_temperature(AdcTime time)
void set_adc_avg_samples(AdcAvgSamples samples)
void set_max_current_a(float max_current_a)
void set_power_sensor(sensor::Sensor *sensor)
void set_current_sensor(sensor::Sensor *sensor)
void set_charge_sensor_c(sensor::Sensor *sensor)
void set_shunt_resistance_ohm(float shunt_resistance_ohm)
void set_adc_range(uint8_t range)
Implementation of SPI Controller mode.
void set_energy_sensor_j(sensor::Sensor *sensor)
Base-class for all sensors.
int8_t current_lsb_scale_factor
void set_energy_sensor_wh(sensor::Sensor *sensor)
esphome::sensor::Sensor * sensor
void set_bus_voltage_sensor(sensor::Sensor *sensor)