Fix second voltage channel if SO150 set

This commit is contained in:
Theo Arends 2023-02-01 12:09:55 +01:00
parent 052b5c2926
commit 1147304781
2 changed files with 4 additions and 0 deletions

View File

@ -189,6 +189,7 @@ bool Bl09XXDecode42(void) {
void Bl09XXUpdateEnergy() {
if (Energy->power_on) { // Powered on
Energy->voltage[0] = (float)Bl09XX.voltage / EnergyGetCalibration(ENERGY_VOLTAGE_CALIBRATION);
Energy->voltage[1] = Energy->voltage[0];
#ifdef DEBUG_BL09XX
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("BL9: U %2_f, T %2_f"), &Energy->voltage[0], &Bl09XX.temperature);
#endif
@ -208,6 +209,7 @@ void Bl09XXUpdateEnergy() {
}
} else { // Powered off
Energy->voltage[0] = 0;
Energy->voltage[1] = 0;
Energy->active_power[0] = Energy->active_power[1] = 0;
Energy->current[0] = Energy->current[1] = 0;
}

View File

@ -462,8 +462,10 @@ void Cse7761GetData(void) {
// Voltage = RmsU * RmsUC * 10 / 0x400000
// Energy->voltage[0] = (float)(((uint64_t)CSE7761Data.voltage_rms * CSE7761Data.coefficient[RmsUC] * 10) >> 22) / 1000; // V
Energy->voltage[0] = ((float)CSE7761Data.voltage_rms / EnergyGetCalibration(ENERGY_VOLTAGE_CALIBRATION)); // V
Energy->voltage[1] = Energy->voltage[0];
#ifdef CSE7761_FREQUENCY
Energy->frequency[0] = (CSE7761Data.frequency) ? ((float)EnergyGetCalibration(ENERGY_FREQUENCY_CALIBRATION) / 8 / CSE7761Data.frequency) : 0; // Hz
Energy->frequency[1] = Energy->frequency[0];
#endif
for (uint32_t channel = 0; channel < 2; channel++) {