ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
atm90e26.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::atm90e26 {
8
10 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH,
11 spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_200KHZ> {
12 SUB_SENSOR(voltage)
13 SUB_SENSOR(current)
14 SUB_SENSOR(power)
15 SUB_SENSOR(reactive_power)
16 SUB_SENSOR(forward_active_energy)
17 SUB_SENSOR(reverse_active_energy)
18 SUB_SENSOR(power_factor)
19 SUB_SENSOR(freq)
20
21 public:
22 void setup() override;
23 void dump_config() override;
24 void update() override;
25
26 void set_line_freq(int freq) { line_freq_ = freq; }
27 void set_meter_constant(float val) { meter_constant_ = val; }
28 void set_pl_const(uint32_t pl_const) { pl_const_ = pl_const; }
29 void set_gain_metering(uint16_t gain) { this->gain_metering_ = gain; }
30 void set_gain_voltage(uint16_t gain) { this->gain_voltage_ = gain; }
31 void set_gain_ct(uint16_t gain) { this->gain_ct_ = gain; }
32 void set_gain_pga(uint16_t gain) { gain_pga_ = gain; }
33 void set_n_line_gain(uint16_t gain) { n_line_gain_ = gain; }
34
35 protected:
36 uint16_t read16_(uint8_t a_register);
37 int read32_(uint8_t addr_h, uint8_t addr_l);
38 void write16_(uint8_t a_register, uint16_t val);
39
40 float get_line_voltage_();
41 float get_line_current_();
42 float get_active_power_();
43 float get_reactive_power_();
44 float get_power_factor_();
47 float get_frequency_();
49
52 uint16_t gain_metering_{7481};
53 uint16_t gain_voltage_{26400};
54 uint16_t gain_ct_{31251};
55 uint16_t gain_pga_{0x4};
56 uint16_t n_line_gain_{0x2};
57 int line_freq_{60};
58 float meter_constant_{3200.0f};
60};
61
62} // namespace esphome::atm90e26
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
uint16_t read16_(uint8_t a_register)
Definition atm90e26.cpp:131
void write16_(uint8_t a_register, uint16_t val)
Definition atm90e26.cpp:147
int read32_(uint8_t addr_h, uint8_t addr_l)
The SPIDevice is what components using the SPI will create.
Definition spi.h:456
AlsGain501 gain
mopeka_std_values val[3]
static void uint32_t