Merge pull request #15973 from mbezuidenhout/bugfix/iem3000

iem3xxx series energy sensor fixes
This commit is contained in:
Theo Arends 2022-07-13 19:53:02 +02:00 committed by GitHub
commit 102d350c82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 30 deletions

View File

@ -1,7 +1,7 @@
/* /*
xnrg_16_iem3000.ino - Schneider Electric iEM3000 series Modbus energy meter support for Tasmota xnrg_16_iem3000.ino - Schneider Electric iEM3000 series Modbus energy meter support for Tasmota
Copyright (C) 2021 Marius Bezuidenhout Copyright (C) 2022 Marius Bezuidenhout
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -47,22 +47,17 @@ const uint16_t Iem3000_start_addresses[] {
0x0bd3, // 3 . IEM3000_L1_VOLTAGE (2/Float32) [V] Voltage L1N 0x0bd3, // 3 . IEM3000_L1_VOLTAGE (2/Float32) [V] Voltage L1N
0x0bd5, // 4 . IEM3000_L2_VOLTAGE (2/Float32) [V] Voltage L2N 0x0bd5, // 4 . IEM3000_L2_VOLTAGE (2/Float32) [V] Voltage L2N
0x0bd7, // 5 . IEM3000_L3_VOLTAGE (2/Float32) [V] Voltage L3N 0x0bd7, // 5 . IEM3000_L3_VOLTAGE (2/Float32) [V] Voltage L3N
0x0bed, // 6 . IEM3000_P1_POWER (2/Float32) [KW] Active Power Phase 1 0x0bed, // 6 . IEM3000_P1_POWER (2/Float32) [kW] Active Power Phase 1
0x0bef, // 7 . IEM3000_P2_POWER (2/Float32) [KW] Active Power Phase 2 0x0bef, // 7 . IEM3000_P2_POWER (2/Float32) [kW] Active Power Phase 2
0x0bf1, // 8 . IEM3000_P3_POWER (2/Float32) [KW] Active Power Phase 3 0x0bf1, // 8 . IEM3000_P3_POWER (2/Float32) [kW] Active Power Phase 3
0x0c25, // 9 . IEM3000_FREQUENCY (2/Float32) [Hz] Frequency 0x0c25, // 9 . IEM3000_FREQUENCY (2/Float32) [Hz] Frequency
#ifdef IEM3000_IEM3155 0x0dbd, // 10 . IEM3000_L1_IMPORT (4/Int64) [Wh] Active Energy Import Phase 1
0xb02b, // 10 . IEM3000_TOTAL_ACTIVE (2/Float32) [Wh] Total Active Energy Import 0x0dc1, // 11 . IEM3000_L1_IMPORT (4/Int64) [Wh] Active Energy Import Phase 1
#else 0x0dc5, // 12 . IEM3000_L1_IMPORT (4/Int64) [Wh] Active Energy Import Phase 1
0xb02b, // 10 . IEM3000_TOTAL_ACTIVE (4/Int64) [Wh] Total Active Energy Import 0x0c83, // 13 . IEM3000_IMPORT (4/Int64) [Wh] Total Active Energy Import
#endif
}; };
#ifdef IEM3000_IEM3155 #define FLOAT_ParamLimit 10
#define FLOAT_ParamLimit 11
#else
#define FLOAT_ParamLimit 10
#endif
struct IEM3000 { struct IEM3000 {
uint8_t read_state = 0; uint8_t read_state = 0;
@ -137,27 +132,15 @@ void IEM3000Every250ms(void)
break; break;
case 6: case 6:
#ifdef IEM3000_IEM3155
Energy.active_power[0] = value*1000; Energy.active_power[0] = value*1000;
#else
Energy.active_power[0] = value;
#endif
break; break;
case 7: case 7:
#ifdef IEM3000_IEM3155
Energy.active_power[1] = value*1000; Energy.active_power[1] = value*1000;
#else
Energy.active_power[1] = value;
#endif
break; break;
case 8: case 8:
#ifdef IEM3000_IEM3155
Energy.active_power[2] = value*1000; Energy.active_power[2] = value*1000;
#else
Energy.active_power[2] = value;
#endif
break; break;
case 9: case 9:
@ -165,11 +148,18 @@ void IEM3000Every250ms(void)
break; break;
case 10: case 10:
#ifdef IEM3000_IEM3155
Energy.import_active[0] = value; Energy.import_active[0] = value;
#else break;
Energy.import_active[0] = value64 * 0.001f; // 1125 => 1.125
#endif case 11:
Energy.import_active[1] = value;
break;
case 12:
Energy.import_active[2] = value;
break;
case 13:
EnergyUpdateTotal(); EnergyUpdateTotal();
break; break;
} }