Fix ESP8266 energy cal range chk

This commit is contained in:
Theo Arends 2024-08-20 17:30:18 +02:00
parent ab2d6c1169
commit ba7161fb00
1 changed files with 1 additions and 3 deletions

View File

@ -988,9 +988,7 @@ void EnergyCommandSetCal(uint32_t cal_type) {
float Igoal = Pgoal / Ugoal; // 0.26087 A
float R = Ugoal / Igoal; // 881,666 Ohm
uint32_t channel = XdrvMailbox.index;
if (channel > Energy->phase_count) { channel = 1; }
channel--;
uint32_t channel = ((1 == XdrvMailbox.index -1) && (2 == Energy->phase_count)) ? 1 : 0;
float Umeas = Energy->voltage[channel]; // 232.0
// Calculate current and power based on measured voltage
float Ical = Umeas / R; // 0.26306 A