ESPHome  2024.11.0
atm90e32.cpp
Go to the documentation of this file.
1 #include "atm90e32.h"
2 #include "atm90e32_reg.h"
3 #include "esphome/core/log.h"
4 #include <cinttypes>
5 
6 namespace esphome {
7 namespace atm90e32 {
8 
9 static const char *const TAG = "atm90e32";
11  if (this->get_publish_interval_flag_()) {
12  this->set_publish_interval_flag_(false);
13  for (uint8_t phase = 0; phase < 3; phase++) {
14  if (this->phase_[phase].voltage_sensor_ != nullptr) {
15  this->phase_[phase].voltage_ = this->get_phase_voltage_(phase);
16  }
17  }
18  for (uint8_t phase = 0; phase < 3; phase++) {
19  if (this->phase_[phase].current_sensor_ != nullptr) {
20  this->phase_[phase].current_ = this->get_phase_current_(phase);
21  }
22  }
23  for (uint8_t phase = 0; phase < 3; phase++) {
24  if (this->phase_[phase].power_sensor_ != nullptr) {
25  this->phase_[phase].active_power_ = this->get_phase_active_power_(phase);
26  }
27  }
28  for (uint8_t phase = 0; phase < 3; phase++) {
29  if (this->phase_[phase].power_factor_sensor_ != nullptr) {
30  this->phase_[phase].power_factor_ = this->get_phase_power_factor_(phase);
31  }
32  }
33  for (uint8_t phase = 0; phase < 3; phase++) {
34  if (this->phase_[phase].reactive_power_sensor_ != nullptr) {
35  this->phase_[phase].reactive_power_ = this->get_phase_reactive_power_(phase);
36  }
37  }
38  for (uint8_t phase = 0; phase < 3; phase++) {
39  if (this->phase_[phase].forward_active_energy_sensor_ != nullptr) {
41  }
42  }
43  for (uint8_t phase = 0; phase < 3; phase++) {
44  if (this->phase_[phase].reverse_active_energy_sensor_ != nullptr) {
46  }
47  }
48  for (uint8_t phase = 0; phase < 3; phase++) {
49  if (this->phase_[phase].phase_angle_sensor_ != nullptr) {
50  this->phase_[phase].phase_angle_ = this->get_phase_angle_(phase);
51  }
52  }
53  for (uint8_t phase = 0; phase < 3; phase++) {
54  if (this->phase_[phase].harmonic_active_power_sensor_ != nullptr) {
56  }
57  }
58  for (uint8_t phase = 0; phase < 3; phase++) {
59  if (this->phase_[phase].peak_current_sensor_ != nullptr) {
60  this->phase_[phase].peak_current_ = this->get_phase_peak_current_(phase);
61  }
62  }
63  // After the local store in collected we can publish them trusting they are withing +-1 haardware sampling
64  for (uint8_t phase = 0; phase < 3; phase++) {
65  if (this->phase_[phase].voltage_sensor_ != nullptr) {
67  }
68  }
69  for (uint8_t phase = 0; phase < 3; phase++) {
70  if (this->phase_[phase].current_sensor_ != nullptr) {
72  }
73  }
74  for (uint8_t phase = 0; phase < 3; phase++) {
75  if (this->phase_[phase].power_sensor_ != nullptr) {
77  }
78  }
79  for (uint8_t phase = 0; phase < 3; phase++) {
80  if (this->phase_[phase].power_factor_sensor_ != nullptr) {
82  }
83  }
84  for (uint8_t phase = 0; phase < 3; phase++) {
85  if (this->phase_[phase].reactive_power_sensor_ != nullptr) {
87  }
88  }
89  for (uint8_t phase = 0; phase < 3; phase++) {
90  if (this->phase_[phase].forward_active_energy_sensor_ != nullptr) {
93  }
94  }
95  for (uint8_t phase = 0; phase < 3; phase++) {
96  if (this->phase_[phase].reverse_active_energy_sensor_ != nullptr) {
99  }
100  }
101  for (uint8_t phase = 0; phase < 3; phase++) {
102  if (this->phase_[phase].phase_angle_sensor_ != nullptr) {
104  }
105  }
106  for (uint8_t phase = 0; phase < 3; phase++) {
107  if (this->phase_[phase].harmonic_active_power_sensor_ != nullptr) {
110  }
111  }
112  for (uint8_t phase = 0; phase < 3; phase++) {
113  if (this->phase_[phase].peak_current_sensor_ != nullptr) {
115  }
116  }
117  if (this->freq_sensor_ != nullptr) {
118  this->freq_sensor_->publish_state(this->get_frequency_());
119  }
120  if (this->chip_temperature_sensor_ != nullptr) {
122  }
123  }
124 }
125 
127  if (this->read16_(ATM90E32_REGISTER_METEREN) != 1) {
128  this->status_set_warning();
129  return;
130  }
131  this->set_publish_interval_flag_(true);
132  this->status_clear_warning();
133 }
134 
137  this->pref_.load(&this->offset_phase_);
138  }
139 };
140 
142  // Run the calibrations and
143  // Setup voltage and current calibration offsets for PHASE A
146  this->write16_(ATM90E32_REGISTER_UOFFSETA, this->phase_[PHASEA].voltage_offset_); // C Voltage offset
149  this->write16_(ATM90E32_REGISTER_IOFFSETA, this->phase_[PHASEA].current_offset_); // C Current offset
150  // Setup voltage and current calibration offsets for PHASE B
153  this->write16_(ATM90E32_REGISTER_UOFFSETB, this->phase_[PHASEB].voltage_offset_); // C Voltage offset
156  this->write16_(ATM90E32_REGISTER_IOFFSETB, this->phase_[PHASEB].current_offset_); // C Current offset
157  // Setup voltage and current calibration offsets for PHASE C
160  this->write16_(ATM90E32_REGISTER_UOFFSETC, this->phase_[PHASEC].voltage_offset_); // C Voltage offset
163  this->write16_(ATM90E32_REGISTER_IOFFSETC, this->phase_[PHASEC].current_offset_); // C Current offset
164  this->pref_.save(&this->offset_phase_);
165  ESP_LOGI(TAG, "PhaseA Vo=%5d PhaseB Vo=%5d PhaseC Vo=%5d", this->offset_phase_[PHASEA].voltage_offset_,
166  this->offset_phase_[PHASEB].voltage_offset_, this->offset_phase_[PHASEC].voltage_offset_);
167  ESP_LOGI(TAG, "PhaseA Io=%5d PhaseB Io=%5d PhaseC Io=%5d", this->offset_phase_[PHASEA].current_offset_,
168  this->offset_phase_[PHASEB].current_offset_, this->offset_phase_[PHASEC].current_offset_);
169 }
170 
172  // Clear the calibrations and
175  this->write16_(ATM90E32_REGISTER_UOFFSETA, this->phase_[PHASEA].voltage_offset_); // C Voltage offset
178  this->write16_(ATM90E32_REGISTER_IOFFSETA, this->phase_[PHASEA].current_offset_); // C Current offset
181  this->write16_(ATM90E32_REGISTER_UOFFSETB, this->phase_[PHASEB].voltage_offset_); // C Voltage offset
184  this->write16_(ATM90E32_REGISTER_IOFFSETB, this->phase_[PHASEB].current_offset_); // C Current offset
187  this->write16_(ATM90E32_REGISTER_UOFFSETC, this->phase_[PHASEC].voltage_offset_); // C Voltage offset
190  this->write16_(ATM90E32_REGISTER_IOFFSETC, this->phase_[PHASEC].current_offset_); // C Current offset
191  this->pref_.save(&this->offset_phase_);
192  ESP_LOGI(TAG, "PhaseA Vo=%5d PhaseB Vo=%5d PhaseC Vo=%5d", this->offset_phase_[PHASEA].voltage_offset_,
193  this->offset_phase_[PHASEB].voltage_offset_, this->offset_phase_[PHASEC].voltage_offset_);
194  ESP_LOGI(TAG, "PhaseA Io=%5d PhaseB Io=%5d PhaseC Io=%5d", this->offset_phase_[PHASEA].current_offset_,
195  this->offset_phase_[PHASEB].current_offset_, this->offset_phase_[PHASEC].current_offset_);
196 }
197 
199  ESP_LOGCONFIG(TAG, "Setting up ATM90E32 Component...");
200  this->spi_setup();
201  if (this->enable_offset_calibration_) {
202  uint32_t hash = fnv1_hash(App.get_friendly_name());
203  this->pref_ = global_preferences->make_preference<Calibration[3]>(hash, true);
204  this->restore_calibrations_();
205  }
206  uint16_t mmode0 = 0x87; // 3P4W 50Hz
207  if (line_freq_ == 60) {
208  mmode0 |= 1 << 12; // sets 12th bit to 1, 60Hz
209  }
210 
211  if (current_phases_ == 2) {
212  mmode0 |= 1 << 8; // sets 8th bit to 1, 3P3W
213  mmode0 |= 0 << 1; // sets 1st bit to 0, phase b is not counted into the all-phase sum energy/power (P/Q/S)
214  }
215 
216  this->write16_(ATM90E32_REGISTER_SOFTRESET, 0x789A); // Perform soft reset
217  delay(6); // Wait for the minimum 5ms + 1ms
218  this->write16_(ATM90E32_REGISTER_CFGREGACCEN, 0x55AA); // enable register config access
219  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != 0x55AA) {
220  ESP_LOGW(TAG, "Could not initialize ATM90E32 IC, check SPI settings");
221  this->mark_failed();
222  return;
223  }
224 
225  this->write16_(ATM90E32_REGISTER_METEREN, 0x0001); // Enable Metering
226  this->write16_(ATM90E32_REGISTER_SAGPEAKDETCFG, 0xFF3F); // Peak Detector time ms (15:8), Sag Period ms (7:0)
227  this->write16_(ATM90E32_REGISTER_PLCONSTH, 0x0861); // PL Constant MSB (default) = 140625000
228  this->write16_(ATM90E32_REGISTER_PLCONSTL, 0xC468); // PL Constant LSB (default)
229  this->write16_(ATM90E32_REGISTER_ZXCONFIG, 0xD654); // ZX2, ZX1, ZX0 pin config
230  this->write16_(ATM90E32_REGISTER_MMODE0, mmode0); // Mode Config (frequency set in main program)
231  this->write16_(ATM90E32_REGISTER_MMODE1, pga_gain_); // PGA Gain Configuration for Current Channels
232  this->write16_(ATM90E32_REGISTER_PSTARTTH, 0x1D4C); // All Active Startup Power Threshold - 0.02A/0.00032 = 7500
233  this->write16_(ATM90E32_REGISTER_QSTARTTH, 0x1D4C); // All Reactive Startup Power Threshold - 50%
234  this->write16_(ATM90E32_REGISTER_SSTARTTH, 0x1D4C); // All Reactive Startup Power Threshold - 50%
235  this->write16_(ATM90E32_REGISTER_PPHASETH, 0x02EE); // Each Phase Active Phase Threshold - 0.002A/0.00032 = 750
236  this->write16_(ATM90E32_REGISTER_QPHASETH, 0x02EE); // Each phase Reactive Phase Threshold - 10%
237  // Setup voltage and current gain for PHASE A
238  this->write16_(ATM90E32_REGISTER_UGAINA, this->phase_[PHASEA].voltage_gain_); // A Voltage rms gain
239  this->write16_(ATM90E32_REGISTER_IGAINA, this->phase_[PHASEA].ct_gain_); // A line current gain
240  // Setup voltage and current gain for PHASE B
241  this->write16_(ATM90E32_REGISTER_UGAINB, this->phase_[PHASEB].voltage_gain_); // B Voltage rms gain
242  this->write16_(ATM90E32_REGISTER_IGAINB, this->phase_[PHASEB].ct_gain_); // B line current gain
243  // Setup voltage and current gain for PHASE C
244  this->write16_(ATM90E32_REGISTER_UGAINC, this->phase_[PHASEC].voltage_gain_); // C Voltage rms gain
245  this->write16_(ATM90E32_REGISTER_IGAINC, this->phase_[PHASEC].ct_gain_); // C line current gain
246  this->write16_(ATM90E32_REGISTER_CFGREGACCEN, 0x0000); // end configuration
247 }
248 
250  ESP_LOGCONFIG("", "ATM90E32:");
251  LOG_PIN(" CS Pin: ", this->cs_);
252  if (this->is_failed()) {
253  ESP_LOGE(TAG, "Communication with ATM90E32 failed!");
254  }
255  LOG_UPDATE_INTERVAL(this);
256  LOG_SENSOR(" ", "Voltage A", this->phase_[PHASEA].voltage_sensor_);
257  LOG_SENSOR(" ", "Current A", this->phase_[PHASEA].current_sensor_);
258  LOG_SENSOR(" ", "Power A", this->phase_[PHASEA].power_sensor_);
259  LOG_SENSOR(" ", "Reactive Power A", this->phase_[PHASEA].reactive_power_sensor_);
260  LOG_SENSOR(" ", "PF A", this->phase_[PHASEA].power_factor_sensor_);
261  LOG_SENSOR(" ", "Active Forward Energy A", this->phase_[PHASEA].forward_active_energy_sensor_);
262  LOG_SENSOR(" ", "Active Reverse Energy A", this->phase_[PHASEA].reverse_active_energy_sensor_);
263  LOG_SENSOR(" ", "Harmonic Power A", this->phase_[PHASEA].harmonic_active_power_sensor_);
264  LOG_SENSOR(" ", "Phase Angle A", this->phase_[PHASEA].phase_angle_sensor_);
265  LOG_SENSOR(" ", "Peak Current A", this->phase_[PHASEA].peak_current_sensor_);
266  LOG_SENSOR(" ", "Voltage B", this->phase_[PHASEB].voltage_sensor_);
267  LOG_SENSOR(" ", "Current B", this->phase_[PHASEB].current_sensor_);
268  LOG_SENSOR(" ", "Power B", this->phase_[PHASEB].power_sensor_);
269  LOG_SENSOR(" ", "Reactive Power B", this->phase_[PHASEB].reactive_power_sensor_);
270  LOG_SENSOR(" ", "PF B", this->phase_[PHASEB].power_factor_sensor_);
271  LOG_SENSOR(" ", "Active Forward Energy B", this->phase_[PHASEB].forward_active_energy_sensor_);
272  LOG_SENSOR(" ", "Active Reverse Energy B", this->phase_[PHASEB].reverse_active_energy_sensor_);
273  LOG_SENSOR(" ", "Harmonic Power A", this->phase_[PHASEB].harmonic_active_power_sensor_);
274  LOG_SENSOR(" ", "Phase Angle A", this->phase_[PHASEB].phase_angle_sensor_);
275  LOG_SENSOR(" ", "Peak Current A", this->phase_[PHASEB].peak_current_sensor_);
276  LOG_SENSOR(" ", "Voltage C", this->phase_[PHASEC].voltage_sensor_);
277  LOG_SENSOR(" ", "Current C", this->phase_[PHASEC].current_sensor_);
278  LOG_SENSOR(" ", "Power C", this->phase_[PHASEC].power_sensor_);
279  LOG_SENSOR(" ", "Reactive Power C", this->phase_[PHASEC].reactive_power_sensor_);
280  LOG_SENSOR(" ", "PF C", this->phase_[PHASEC].power_factor_sensor_);
281  LOG_SENSOR(" ", "Active Forward Energy C", this->phase_[PHASEC].forward_active_energy_sensor_);
282  LOG_SENSOR(" ", "Active Reverse Energy C", this->phase_[PHASEC].reverse_active_energy_sensor_);
283  LOG_SENSOR(" ", "Harmonic Power A", this->phase_[PHASEC].harmonic_active_power_sensor_);
284  LOG_SENSOR(" ", "Phase Angle A", this->phase_[PHASEC].phase_angle_sensor_);
285  LOG_SENSOR(" ", "Peak Current A", this->phase_[PHASEC].peak_current_sensor_);
286  LOG_SENSOR(" ", "Frequency", this->freq_sensor_);
287  LOG_SENSOR(" ", "Chip Temp", this->chip_temperature_sensor_);
288 }
289 
291 
292 // R/C registers can conly be cleared after the LastSPIData register is updated (register 78H)
293 // Peakdetect period: 05H. Bit 15:8 are PeakDet_period in ms. 7:0 are Sag_period
294 // Default is 143FH (20ms, 63ms)
295 uint16_t ATM90E32Component::read16_(uint16_t a_register) {
296  uint8_t addrh = (1 << 7) | ((a_register >> 8) & 0x03);
297  uint8_t addrl = (a_register & 0xFF);
298  uint8_t data[2];
299  uint16_t output;
300  this->enable();
302  this->write_byte(addrh);
303  this->write_byte(addrl);
304  this->read_array(data, 2);
305  this->disable();
306 
307  output = (uint16_t(data[0] & 0xFF) << 8) | (data[1] & 0xFF);
308  ESP_LOGVV(TAG, "read16_ 0x%04" PRIX16 " output 0x%04" PRIX16, a_register, output);
309  return output;
310 }
311 
312 int ATM90E32Component::read32_(uint16_t addr_h, uint16_t addr_l) {
313  const uint16_t val_h = this->read16_(addr_h);
314  const uint16_t val_l = this->read16_(addr_l);
315  const int32_t val = (val_h << 16) | val_l;
316 
317  ESP_LOGVV(TAG,
318  "read32_ addr_h 0x%04" PRIX16 " val_h 0x%04" PRIX16 " addr_l 0x%04" PRIX16 " val_l 0x%04" PRIX16
319  " = %" PRId32,
320  addr_h, val_h, addr_l, val_l, val);
321 
322  return val;
323 }
324 
325 void ATM90E32Component::write16_(uint16_t a_register, uint16_t val) {
326  ESP_LOGVV(TAG, "write16_ 0x%04" PRIX16 " val 0x%04" PRIX16, a_register, val);
327  this->enable();
328  this->write_byte16(a_register);
329  this->write_byte16(val);
330  this->disable();
331  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != val)
332  ESP_LOGW(TAG, "SPI write error 0x%04X val 0x%04X", a_register, val);
333 }
334 
335 float ATM90E32Component::get_local_phase_voltage_(uint8_t phase) { return this->phase_[phase].voltage_; }
336 
337 float ATM90E32Component::get_local_phase_current_(uint8_t phase) { return this->phase_[phase].current_; }
338 
339 float ATM90E32Component::get_local_phase_active_power_(uint8_t phase) { return this->phase_[phase].active_power_; }
340 
341 float ATM90E32Component::get_local_phase_reactive_power_(uint8_t phase) { return this->phase_[phase].reactive_power_; }
342 
343 float ATM90E32Component::get_local_phase_power_factor_(uint8_t phase) { return this->phase_[phase].power_factor_; }
344 
346  return this->phase_[phase].forward_active_energy_;
347 }
348 
350  return this->phase_[phase].reverse_active_energy_;
351 }
352 
353 float ATM90E32Component::get_local_phase_angle_(uint8_t phase) { return this->phase_[phase].phase_angle_; }
354 
356  return this->phase_[phase].harmonic_active_power_;
357 }
358 
359 float ATM90E32Component::get_local_phase_peak_current_(uint8_t phase) { return this->phase_[phase].peak_current_; }
360 
362  const uint16_t voltage = this->read16_(ATM90E32_REGISTER_URMS + phase);
363  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != voltage)
364  ESP_LOGW(TAG, "SPI URMS voltage register read error.");
365  return (float) voltage / 100;
366 }
367 
369  const uint8_t reads = 10;
370  uint32_t accumulation = 0;
371  uint16_t voltage = 0;
372  for (uint8_t i = 0; i < reads; i++) {
373  voltage = this->read16_(ATM90E32_REGISTER_URMS + phase);
374  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != voltage)
375  ESP_LOGW(TAG, "SPI URMS voltage register read error.");
376  accumulation += voltage;
377  }
378  voltage = accumulation / reads;
379  this->phase_[phase].voltage_ = (float) voltage / 100;
380  return this->phase_[phase].voltage_;
381 }
382 
384  const uint8_t reads = 10;
385  uint32_t accumulation = 0;
386  uint16_t current = 0;
387  for (uint8_t i = 0; i < reads; i++) {
388  current = this->read16_(ATM90E32_REGISTER_IRMS + phase);
389  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != current)
390  ESP_LOGW(TAG, "SPI IRMS current register read error.");
391  accumulation += current;
392  }
393  current = accumulation / reads;
394  this->phase_[phase].current_ = (float) current / 1000;
395  return this->phase_[phase].current_;
396 }
397 
399  const uint16_t current = this->read16_(ATM90E32_REGISTER_IRMS + phase);
400  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != current)
401  ESP_LOGW(TAG, "SPI IRMS current register read error.");
402  return (float) current / 1000;
403 }
404 
406  const int val = this->read32_(ATM90E32_REGISTER_PMEAN + phase, ATM90E32_REGISTER_PMEANLSB + phase);
407  return val * 0.00032f;
408 }
409 
411  const int val = this->read32_(ATM90E32_REGISTER_QMEAN + phase, ATM90E32_REGISTER_QMEANLSB + phase);
412  return val * 0.00032f;
413 }
414 
416  const int16_t powerfactor = this->read16_(ATM90E32_REGISTER_PFMEAN + phase);
417  if (this->read16_(ATM90E32_REGISTER_LASTSPIDATA) != powerfactor)
418  ESP_LOGW(TAG, "SPI power factor read error.");
419  return (float) powerfactor / 1000;
420 }
421 
423  const uint16_t val = this->read16_(ATM90E32_REGISTER_APENERGY + phase);
424  if ((UINT32_MAX - this->phase_[phase].cumulative_forward_active_energy_) > val) {
426  } else {
428  }
429  return ((float) this->phase_[phase].cumulative_forward_active_energy_ * 10 / 3200);
430 }
431 
433  const uint16_t val = this->read16_(ATM90E32_REGISTER_ANENERGY);
434  if (UINT32_MAX - this->phase_[phase].cumulative_reverse_active_energy_ > val) {
436  } else {
438  }
439  return ((float) this->phase_[phase].cumulative_reverse_active_energy_ * 10 / 3200);
440 }
441 
443  int val = this->read32_(ATM90E32_REGISTER_PMEANH + phase, ATM90E32_REGISTER_PMEANHLSB + phase);
444  return val * 0.00032f;
445 }
446 
448  uint16_t val = this->read16_(ATM90E32_REGISTER_PANGLE + phase) / 10.0;
449  return (float) (val > 180) ? val - 360.0 : val;
450 }
451 
453  int16_t val = (float) this->read16_(ATM90E32_REGISTER_IPEAK + phase);
454  if (!this->peak_current_signed_)
455  val = abs(val);
456  // phase register * phase current gain value / 1000 * 2^13
457  return (float) (val * this->phase_[phase].ct_gain_ / 8192000.0);
458 }
459 
461  const uint16_t freq = this->read16_(ATM90E32_REGISTER_FREQ);
462  return (float) freq / 100;
463 }
464 
466  const uint16_t ctemp = this->read16_(ATM90E32_REGISTER_TEMP);
467  return (float) ctemp;
468 }
469 
471  const uint8_t num_reads = 5;
472  uint64_t total_value = 0;
473  for (int i = 0; i < num_reads; ++i) {
474  const uint32_t measurement_value = read32_(ATM90E32_REGISTER_URMS + phase, ATM90E32_REGISTER_URMSLSB + phase);
475  total_value += measurement_value;
476  }
477  const uint32_t average_value = total_value / num_reads;
478  const uint32_t shifted_value = average_value >> 7;
479  const uint32_t voltage_offset = ~shifted_value + 1;
480  return voltage_offset & 0xFFFF; // Take the lower 16 bits
481 }
482 
484  const uint8_t num_reads = 5;
485  uint64_t total_value = 0;
486  for (int i = 0; i < num_reads; ++i) {
487  const uint32_t measurement_value = read32_(ATM90E32_REGISTER_IRMS + phase, ATM90E32_REGISTER_IRMSLSB + phase);
488  total_value += measurement_value;
489  }
490  const uint32_t average_value = total_value / num_reads;
491  const uint32_t current_offset = ~average_value + 1;
492  return current_offset & 0xFFFF; // Take the lower 16 bits
493 }
494 
495 } // namespace atm90e32
496 } // namespace esphome
float get_local_phase_active_power_(uint8_t)
Definition: atm90e32.cpp:339
float get_setup_priority() const override
Definition: atm90e32.cpp:290
void write16_(uint16_t a_register, uint16_t val)
Definition: atm90e32.cpp:325
void status_set_warning(const char *message="unspecified")
Definition: component.cpp:151
bool is_failed() const
Definition: component.cpp:143
int read32_(uint16_t addr_h, uint16_t addr_l)
Definition: atm90e32.cpp:312
struct esphome::atm90e32::ATM90E32Component::Calibration offset_phase_[3]
const std::string & get_friendly_name() const
Get the friendly name of this Application set by pre_setup().
Definition: application.h:205
mopeka_std_values val[4]
GPIOPin * cs_
Definition: spi.h:378
void delay_microseconds_safe(uint32_t us)
Delay for the given amount of microseconds, possibly yielding to other processes during the wait...
Definition: helpers.cpp:753
static const uint8_t PHASEC
Definition: atm90e32.h:20
static const uint8_t PHASEB
Definition: atm90e32.h:19
bool save(const T *src)
Definition: preferences.h:21
float get_phase_forward_active_energy_(uint8_t)
Definition: atm90e32.cpp:422
static const uint8_t PHASEA
Definition: atm90e32.h:18
ESPPreferences * global_preferences
void status_clear_warning()
Definition: component.cpp:166
void publish_state(float state)
Publish a new state to the front-end.
Definition: sensor.cpp:39
struct esphome::atm90e32::ATM90E32Component::ATM90E32Phase phase_[3]
float get_local_phase_forward_active_energy_(uint8_t)
Definition: atm90e32.cpp:345
uint16_t calibrate_voltage_offset_phase(uint8_t)
Definition: atm90e32.cpp:470
Application App
Global storage of Application pointer - only one Application can exist.
float get_phase_reverse_active_energy_(uint8_t)
Definition: atm90e32.cpp:432
float get_local_phase_peak_current_(uint8_t)
Definition: atm90e32.cpp:359
float get_phase_harmonic_active_power_(uint8_t)
Definition: atm90e32.cpp:442
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
uint32_t fnv1_hash(const std::string &str)
Calculate a FNV-1 hash of str.
Definition: helpers.cpp:183
uint16_t read16_(uint16_t a_register)
Definition: atm90e32.cpp:295
virtual void mark_failed()
Mark this component as failed.
Definition: component.cpp:118
const float IO
For components that represent GPIO pins like PCF8573.
Definition: component.cpp:17
sensor::Sensor * chip_temperature_sensor_
Definition: atm90e32.h:130
float get_local_phase_reverse_active_energy_(uint8_t)
Definition: atm90e32.cpp:349
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint16_t calibrate_current_offset_phase(uint8_t)
Definition: atm90e32.cpp:483
float get_local_phase_harmonic_active_power_(uint8_t)
Definition: atm90e32.cpp:355
float get_local_phase_power_factor_(uint8_t)
Definition: atm90e32.cpp:343
void set_publish_interval_flag_(bool flag)
Definition: atm90e32.h:89
float get_local_phase_reactive_power_(uint8_t)
Definition: atm90e32.cpp:341
void IRAM_ATTR HOT delay(uint32_t ms)
Definition: core.cpp:26