From 903d3174b241d0abe5ce2abe3f5c53a89002dd7c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 15 Sep 2022 11:22:09 +0200 Subject: [PATCH] Fix ADE7953 apparent and reactive power calibration --- .../tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino | 8 +++++--- tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino b/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino index 789ce5bdb..b0e9fe188 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino @@ -541,12 +541,14 @@ void CmndDspLine(void) { } if (9 == XdrvMailbox.index) { // DspLine9 = Show sensor JSON + // Example 1: SCD30 I2C connected (GPIO25 = I2C SCL, GPIO26 = I2C SDA) // {"SCD30":{"CarbonDioxide":746,"eCO2":727,"Temperature":30.6,"Humidity":43.6,"DewPoint":16.8}} // index: 1 2 3 4 5 6 // unit: 0 0 (ppm) 0 (ppm) 1 (C or F) 2 (%RH) 1 (C or F) - // {"ENERGY":{"TotalStartTime":"2022-07-15T13:44:23","Total":0.086,"Yesterday":0.002,"Today":0.005,"Power":0.96,"ApparentPower":7.60,"ReactivePower":7.50,"Factor":0.13,"Voltage":227.9,"Current":0.033}} - // index: 1 2 3 4 5 6 7 8 9 10 11 - // unit: 0 0 4 (kWh) 4 (kWh) 4 (kWh) 4 (W) 0 (VA) 0 (VAr) 0 3 (V) 3 (A) + // Example 2: PZEM016 serial connected (GPIO25 = PZEM0XX Tx, GPIO26 = PZEM016 Rx) + // {"ENERGY":{"TotalStartTime":"2022-07-05T16:01:39","Total":0.000,"Yesterday":0.000,"Today":0.000,"Power":0.00,"ApparentPower":0.00,"ReactivePower":0.00,"Factor":0.00,"Frequency":50,"Voltage":231.7,"Current":0.000}} + // index: 1 2 3 4 5 6 7 8 9 10 11 12 + // unit: 0 0 4 (kWh) 4 (kWh) 4 (kWh) 4 (W) 0 (VA) 0 (VAr) 0 0 3 (V) 3 (A) TM1621GetSensors(1); } } diff --git a/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino b/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino index ad1aabff4..69e943db8 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino @@ -417,16 +417,16 @@ bool Ade7953SetDefaults(const char* json) { } JsonParserObject apparent = powers[PSTR("apparent")].getObject(); if (apparent) { - val = totactive[PSTR("a")]; + val = apparent[PSTR("a")]; if (val) { Ade7953.calib_data[ADE7953_CAL_AVAGAIN] = val.getInt(); } - val = totactive[PSTR("b")]; + val = apparent[PSTR("b")]; if (val) { Ade7953.calib_data[ADE7953_CAL_BVAGAIN] = val.getInt(); } } JsonParserObject reactive = powers[PSTR("reactive")].getObject(); if (reactive) { - val = totactive[PSTR("a")]; + val = reactive[PSTR("a")]; if (val) { Ade7953.calib_data[ADE7953_CAL_AVARGAIN] = val.getInt(); } - val = totactive[PSTR("b")]; + val = reactive[PSTR("b")]; if (val) { Ade7953.calib_data[ADE7953_CAL_BVARGAIN] = val.getInt(); } } }