iem3xxx series energy sensor fixes

This commit is contained in:
Marius Bezuidenhout 2022-07-13 11:23:03 +02:00
parent 9f9155da9b
commit 3e8428e857
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
Copyright (C) 2021 Marius Bezuidenhout
Copyright (C) 2022 Marius Bezuidenhout
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
@ -47,22 +47,17 @@ const uint16_t Iem3000_start_addresses[] {
0x0bd3, // 3 . IEM3000_L1_VOLTAGE (2/Float32) [V] Voltage L1N
0x0bd5, // 4 . IEM3000_L2_VOLTAGE (2/Float32) [V] Voltage L2N
0x0bd7, // 5 . IEM3000_L3_VOLTAGE (2/Float32) [V] Voltage L3N
0x0bed, // 6 . IEM3000_P1_POWER (2/Float32) [KW] Active Power Phase 1
0x0bef, // 7 . IEM3000_P2_POWER (2/Float32) [KW] Active Power Phase 2
0x0bf1, // 8 . IEM3000_P3_POWER (2/Float32) [KW] Active Power Phase 3
0x0bed, // 6 . IEM3000_P1_POWER (2/Float32) [kW] Active Power Phase 1
0x0bef, // 7 . IEM3000_P2_POWER (2/Float32) [kW] Active Power Phase 2
0x0bf1, // 8 . IEM3000_P3_POWER (2/Float32) [kW] Active Power Phase 3
0x0c25, // 9 . IEM3000_FREQUENCY (2/Float32) [Hz] Frequency
#ifdef IEM3000_IEM3155
0xb02b, // 10 . IEM3000_TOTAL_ACTIVE (2/Float32) [Wh] Total Active Energy Import
#else
0xb02b, // 10 . IEM3000_TOTAL_ACTIVE (4/Int64) [Wh] Total Active Energy Import
#endif
0x0dbd, // 10 . IEM3000_L1_IMPORT (4/Int64) [Wh] Active Energy Import Phase 1
0x0dc1, // 11 . IEM3000_L1_IMPORT (4/Int64) [Wh] Active Energy Import Phase 1
0x0dc5, // 12 . IEM3000_L1_IMPORT (4/Int64) [Wh] Active Energy Import Phase 1
0x0c83, // 13 . IEM3000_IMPORT (4/Int64) [Wh] Total Active Energy Import
};
#ifdef IEM3000_IEM3155
#define FLOAT_ParamLimit 11
#else
#define FLOAT_ParamLimit 10
#endif
#define FLOAT_ParamLimit 10
struct IEM3000 {
uint8_t read_state = 0;
@ -137,27 +132,15 @@ void IEM3000Every250ms(void)
break;
case 6:
#ifdef IEM3000_IEM3155
Energy.active_power[0] = value*1000;
#else
Energy.active_power[0] = value;
#endif
break;
case 7:
#ifdef IEM3000_IEM3155
Energy.active_power[1] = value*1000;
#else
Energy.active_power[1] = value;
#endif
break;
case 8:
#ifdef IEM3000_IEM3155
Energy.active_power[2] = value*1000;
#else
Energy.active_power[2] = value;
#endif
break;
case 9:
@ -165,11 +148,18 @@ void IEM3000Every250ms(void)
break;
case 10:
#ifdef IEM3000_IEM3155
Energy.import_active[0] = value;
#else
Energy.import_active[0] = value64 * 0.001f; // 1125 => 1.125
#endif
break;
case 11:
Energy.import_active[1] = value;
break;
case 12:
Energy.import_active[2] = value;
break;
case 13:
EnergyUpdateTotal();
break;
}