From 435be84ff3ed1e5186da312d73ed072a7465b5fa Mon Sep 17 00:00:00 2001 From: Norbert Richter Date: Tue, 9 Feb 2021 16:13:40 +0100 Subject: [PATCH] Add SDM72 Modbus energy meter --- BUILDS.md | 1 + CHANGELOG.md | 3 + tasmota/i18n.h | 2 + tasmota/language/af_AF.h | 6 +- tasmota/language/bg_BG.h | 6 +- tasmota/language/cs_CZ.h | 6 +- tasmota/language/de_DE.h | 6 +- tasmota/language/el_GR.h | 6 +- tasmota/language/en_GB.h | 6 +- tasmota/language/es_ES.h | 6 +- tasmota/language/fr_FR.h | 6 +- tasmota/language/fy_NL.h | 6 +- tasmota/language/he_HE.h | 6 +- tasmota/language/hu_HU.h | 6 +- tasmota/language/it_IT.h | 6 +- tasmota/language/ko_KO.h | 6 +- tasmota/language/nl_NL.h | 6 +- tasmota/language/pl_PL.h | 6 +- tasmota/language/pt_BR.h | 6 +- tasmota/language/pt_PT.h | 6 +- tasmota/language/ro_RO.h | 6 +- tasmota/language/ru_RU.h | 6 +- tasmota/language/sk_SK.h | 6 +- tasmota/language/sv_SE.h | 6 +- tasmota/language/tr_TR.h | 6 +- tasmota/language/uk_UA.h | 6 +- tasmota/language/vi_VN.h | 6 +- tasmota/language/zh_CN.h | 6 +- tasmota/language/zh_TW.h | 6 +- tasmota/my_user_config.h | 3 + tasmota/support_features.ino | 4 +- tasmota/tasmota_configurations.h | 6 + tasmota/tasmota_template.h | 6 + tasmota/xdrv_03_energy.ino | 24 ++-- tasmota/xnrg_18_sdm72.ino | 210 +++++++++++++++++++++++++++++++ tools/decode-status.py | 2 +- 36 files changed, 377 insertions(+), 40 deletions(-) create mode 100644 tasmota/xnrg_18_sdm72.ino diff --git a/BUILDS.md b/BUILDS.md index e882329d9ffa..9cf437df27a3 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -67,6 +67,7 @@ | USE_PZEM_AC | - | - | x | x | x | - | - | | USE_PZEM_DC | - | - | x | x | x | - | - | | USE_MCP39F501 | - | x | x | x | x | - | - | +| USE_SDM72 | - | - | - | - | x | - | - | | USE_SDM120 | - | - | - | - | x | - | - | | USE_SDM630 | - | - | - | - | x | - | - | | USE_DDS2382 | - | - | - | - | x | - | - | diff --git a/CHANGELOG.md b/CHANGELOG.md index fc723c450c57..30671cf0d420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development ## [9.2.0.6] +### Added +- Support for Eastron SDM72D-M three phase 100A Modbus energy meter (#10862) + ### Changed - Removed migration support for versions before v8.1.0 (Doris) - ESP32 Increase number of switch GPIOs from 8 to 28 diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 0eb558bbe1b2..30b479fc635b 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -73,6 +73,7 @@ #define D_JSON_EXPORT "Export" #define D_JSON_EXPORT_ACTIVE "ExportActive" #define D_JSON_EXPORT_REACTIVE "ExportReactive" +#define D_JSON_EXPORT_POWER "ExportPower" #define D_JSON_FAILED "Failed" #define D_JSON_FALLBACKTOPIC "FallbackTopic" #define D_JSON_FEATURES "Features" @@ -99,6 +100,7 @@ #define D_JSON_ID "Id" #define D_JSON_ILLUMINANCE "Illuminance" #define D_JSON_IMPORT_ACTIVE "ImportActive" +#define D_JSON_IMPORT_POWER "ImportPower" #define D_JSON_IMPORT_REACTIVE "ImportReactive" #define D_JSON_INFRARED "Infrared" #define D_JSON_UNKNOWN "Unknown" diff --git a/tasmota/language/af_AF.h b/tasmota/language/af_AF.h index 2a6acd73d227..05f4c7154e84 100644 --- a/tasmota/language/af_AF.h +++ b/tasmota/language/af_AF.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Uitvoer krag" +#define D_IMPORT_POWER "Invoer krag" #define D_PHASE_ANGLE "Fasehoek" #define D_IMPORT_ACTIVE "Invoer aktief" #define D_EXPORT_ACTIVE "Uitvoer aktief" diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index b5a450bd76ec..1e6a0d5ef2b5 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -629,6 +629,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -833,7 +835,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Фазов ъгъл" #define D_IMPORT_ACTIVE "Входна активна мощност" #define D_EXPORT_ACTIVE "Изходна активна мощност" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index 6449196c5c26..1f1e4f156847 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index 1af8a09aca76..7817531a5ea6 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Exportiere Leistung" +#define D_IMPORT_POWER "Importiere Leistung" #define D_PHASE_ANGLE "Phasenwinkel" #define D_IMPORT_ACTIVE "Importiere Wirk" #define D_EXPORT_ACTIVE "Exportiere Wirk" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index 0409a9696258..4fbf89dd9a33 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index 2cde1ccdf9fc..af7cef8d6fb7 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index 0147a88f575c..8f99d5fb1bf3 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Ángulo de Fase" #define D_IMPORT_ACTIVE "P. Activa Entrante" #define D_EXPORT_ACTIVE "P. Activa Saliente" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index 2d2a8aabaf3e..958dca519b98 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -626,6 +626,8 @@ #define D_SENSOR_SBR_TX "SerBr TX" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 TX" #define D_SENSOR_SDM120_RX "SDMx20 RX" #define D_SENSOR_SDM630_TX "SDM630 TX" @@ -829,7 +831,9 @@ #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Angle de phase" #define D_IMPORT_ACTIVE "Énergie act conso" #define D_EXPORT_ACTIVE "Énergie act fournie" diff --git a/tasmota/language/fy_NL.h b/tasmota/language/fy_NL.h index 29167a6c67c6..1460d1d9958c 100644 --- a/tasmota/language/fy_NL.h +++ b/tasmota/language/fy_NL.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Eksportearje krêft" +#define D_IMPORT_POWER "Ymportearje krêft" #define D_PHASE_ANGLE "Faze hoeke" #define D_IMPORT_ACTIVE "Ymportearje echt" #define D_EXPORT_ACTIVE "Eksportearje echt" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index 11b2e385e8f6..b90029ede1a0 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index f7b862d962f2..2c74d5134de9 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Fázisszög" #define D_IMPORT_ACTIVE "Bejövő aktív" #define D_EXPORT_ACTIVE "Kimenő aktív" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index b4f8a0bb472a..0543032f3d7e 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr - TX" #define D_SENSOR_SR04_TRIG "SR04 Tri - TX" #define D_SENSOR_SR04_ECHO "SR04 Ech - RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 - TX" #define D_SENSOR_SDM120_RX "SDMx20 - RX" #define D_SENSOR_SDM630_TX "SDM630 - TX" @@ -833,7 +835,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Potenza esportata" +#define D_IMPORT_POWER "Potenza importata" #define D_PHASE_ANGLE "Angolo Fase" #define D_IMPORT_ACTIVE "Potenza attiva importata" #define D_EXPORT_ACTIVE "Potenza attiva esportata" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index 22d0b17e17bc..d96b76f76138 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index 908e8c5767c4..3c9a0773c790 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export vermogen" +#define D_IMPORT_POWER "Import vermogen" #define D_PHASE_ANGLE "Fase hoek" #define D_IMPORT_ACTIVE "Import werkelijk" #define D_EXPORT_ACTIVE "Export werkelijk" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index 9a7c2cd0355a..d477cccd304c 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Przesunięcie faz" #define D_IMPORT_ACTIVE "Czynna pobrana" #define D_EXPORT_ACTIVE "Czynna oddana" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index 84aef8ede77c..3660bdaa16ff 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "W/h" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Ângulo de Fase" #define D_IMPORT_ACTIVE "Importar Ativo" #define D_EXPORT_ACTIVE "Exportar Ativo" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index a02bb9a67faa..3b4ea261464c 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Ângulo de fase" #define D_IMPORT_ACTIVE "Ativo importado" #define D_EXPORT_ACTIVE "Ativo exportado" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index 9a1ed142a0de..c6810406db65 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Unghi de fază" #define D_IMPORT_ACTIVE "Import Activ" #define D_EXPORT_ACTIVE "Export Activ" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index a2029c1180df..8941a770d765 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "ВтЧ" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Угол фазы" #define D_IMPORT_ACTIVE "Импорт активной мощности" #define D_EXPORT_ACTIVE "Экспорт активной мощности" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index a7e2f2f9a691..e30692e58474 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index 32708fe6aa95..dad72de28fb8 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Fasvinkel" #define D_IMPORT_ACTIVE "Import aktiv" #define D_EXPORT_ACTIVE "Export aktiv" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index b45a886e3aa8..ab7d00a31bf1 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index 8fb58deed447..c2c1cbd72da2 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Вт/г" #define D_UNIT_WATT_METER_QUADRAT "Вт/м²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Кут фази" #define D_IMPORT_ACTIVE "Активна вхід" #define D_EXPORT_ACTIVE "Активна вихід" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index 1bc4ffe71111..e7187438155f 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "Wh" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Góc pha" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index bc929c300923..186a013eb0e2 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "瓦时" #define D_UNIT_WATT_METER_QUADRAT "瓦/平米" -//SDM220, SDM120, LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "相位角" #define D_IMPORT_ACTIVE "有功输入" #define D_EXPORT_ACTIVE "有功输出" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 51c8d50f8994..5a8e3591fd3f 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -630,6 +630,8 @@ #define D_SENSOR_SBR_TX "SerBr Tx" #define D_SENSOR_SR04_TRIG "SR04 Tri/TX" #define D_SENSOR_SR04_ECHO "SR04 Ech/RX" +#define D_SENSOR_SDM72_TX "SDM72 Tx" +#define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" @@ -834,7 +836,9 @@ #define D_UNIT_WATTHOUR "瓦小時" #define D_UNIT_WATT_METER_QUADRAT "W/m²" -//SDM220、 SDM120、 LE01MR +//SDM220, SDM120, SDM72, LE01MR +#define D_EXPORT_POWER "Export Power" +#define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "相量(Phase Angle)" #define D_IMPORT_ACTIVE "Import Active" #define D_EXPORT_ACTIVE "Export Active" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 25a629c05d3f..fc4becb48b6a 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -682,6 +682,9 @@ #define USE_PZEM_AC // Add support for PZEM014,016 Energy monitor (+1k1 code) #define USE_PZEM_DC // Add support for PZEM003,017 Energy monitor (+1k1 code) #define USE_MCP39F501 // Add support for MCP39F501 Energy monitor as used in Shelly 2 (+3k1 code) +//#define USE_SDM72 // Add support for Eastron SDM72-Modbus energy monitor (+0k3 code) + #define SDM72_SPEED 9600 // SDM72-Modbus RS485 serial speed (default: 9600 baud) + // #define SDM72_IMPEXP // Show additonal import/export active energy and power in MQTT and Web (+0k5 code) //#define USE_SDM120 // Add support for Eastron SDM120-Modbus energy monitor (+1k1 code) #define SDM120_SPEED 2400 // SDM120-Modbus RS485 serial speed (default: 2400 baud) //#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy monitor (+0k6 code) diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 1d17193e51ae..8e17664393cf 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -712,7 +712,9 @@ void ResponseAppendFeatures(void) #if defined(USE_I2C) && defined(USE_TOF10120) feature7 |= 0x10000000; // xsns_84_tof10120 #endif -// feature7 |= 0x20000000; +#if defined(USE_ENERGY_SENSOR) && defined(USE_SDM72) + feature7 |= 0x20000000; // xnrg_18_sdm72.ino +#endif // feature7 |= 0x40000000; // feature7 |= 0x80000000; } diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index de60b84e1836..6d7664f8b3b9 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -185,6 +185,7 @@ #define USE_PZEM_AC // Add support for PZEM014,016 Energy monitor (+1k1 code) #define USE_PZEM_DC // Add support for PZEM003,017 Energy monitor (+1k1 code) #define USE_MCP39F501 // Add support for MCP39F501 Energy monitor as used in Shelly 2 (+3k1 code) +#define USE_SDM72 // Add support for Eastron SDM72-Modbus energy monitor (+0k3 code) #define USE_SDM120 // Add support for Eastron SDM120-Modbus energy monitor (+1k1 code) #define USE_SDM630 // Add support for Eastron SDM630-Modbus energy monitor (+0k6 code) #define USE_DDS2382 // Add support for Hiking DDS2382 Modbus energy monitor (+0k6 code) @@ -287,6 +288,7 @@ #undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor #undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor #undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2 + #undef USE_SDM72 // Disable support for Eastron SDM72-Modbus energy meter #undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter #undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code) #undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code) @@ -388,6 +390,7 @@ #undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor #undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor #undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2 + #undef USE_SDM72 // Disable support for Eastron SDM72-Modbus energy meter #undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter #undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code) #undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code) @@ -563,6 +566,7 @@ #undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor #undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor #undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2 +#undef USE_SDM72 // Disable support for Eastron SDM72-Modbus energy meter #undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter #undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code) #undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code) @@ -700,6 +704,7 @@ #undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor #undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor //#undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2 +#undef USE_SDM72 // Disable support for Eastron SDM72-Modbus energy meter #undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter #undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code) #undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code) @@ -841,6 +846,7 @@ #undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor #undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor #undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2 +#undef USE_SDM72 // Disable support for Eastron SDM72-Modbus energy meter #undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter #undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code) #undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code) diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index dbdc41cce0d7..98567ca42b22 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -148,6 +148,7 @@ enum UserSelectablePins { GPIO_BS814_CLK, GPIO_BS814_DAT, // Holtek BS814A2 touch ctrlr GPIO_WIEGAND_D0, GPIO_WIEGAND_D1, // Wiegand Data lines GPIO_NEOPOOL_TX, GPIO_NEOPOOL_RX, // Sugar Valley RS485 interface + GPIO_SDM72_TX, GPIO_SDM72_RX, // SDM72 Serial interface GPIO_SENSOR_END }; enum ProgramSelectablePins { @@ -316,6 +317,7 @@ const char kSensorNames[] PROGMEM = D_SENSOR_BS814_CLK "|" D_SENSOR_BS814_DAT "|" D_SENSOR_WIEGAND_D0 "|" D_SENSOR_WIEGAND_D1 "|" D_SENSOR_NEOPOOL_TX "|" D_SENSOR_NEOPOOL_RX "|" + D_SENSOR_SDM72_TX "|" D_SENSOR_SDM72_RX "|" ; const char kSensorNamesFixed[] PROGMEM = @@ -605,6 +607,10 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_WE517_TX), // WE517 Serial interface AGPIO(GPIO_WE517_RX), // WE517 Serial interface #endif +#ifdef USE_SDM72 + AGPIO(GPIO_SDM72_TX), // SDM72 Serial interface + AGPIO(GPIO_SDM72_RX), // SDM72 Serial interface +#endif #endif // USE_ENERGY_SENSOR /*-------------------------------------------------------------------------------------------*\ diff --git a/tasmota/xdrv_03_energy.ino b/tasmota/xdrv_03_energy.ino index f253838aa9d2..d63472a9d17a 100644 --- a/tasmota/xdrv_03_energy.ino +++ b/tasmota/xdrv_03_energy.ino @@ -80,9 +80,9 @@ struct ENERGY { float power_factor[3] = { NAN, NAN, NAN }; // 0.12 float frequency[3] = { NAN, NAN, NAN }; // 123.1 Hz -#ifdef SDM630_IMPORT +#if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) float import_active[3] = { NAN, NAN, NAN }; // 123.123 kWh -#endif // SDM630_IMPORT +#endif // SDM630_IMPORT || SDM72_IMPEXP float export_active[3] = { NAN, NAN, NAN }; // 123.123 kWh float start_energy = 0; // 12345.12345 kWh total previous @@ -919,10 +919,10 @@ const char HTTP_ENERGY_SNS2[] PROGMEM = const char HTTP_ENERGY_SNS3[] PROGMEM = "{s}" D_EXPORT_ACTIVE "{m}%s " D_UNIT_KILOWATTHOUR "{e}"; -#ifdef SDM630_IMPORT +#if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) const char HTTP_ENERGY_SNS4[] PROGMEM = "{s}" D_IMPORT_ACTIVE "{m}%s " D_UNIT_KILOWATTHOUR "{e}"; -#endif // SDM630_IMPORT +#endif // SDM630_IMPORT || SDM72_IMPEXP #endif // USE_WEBSERVER void EnergyShow(bool json) @@ -987,17 +987,17 @@ void EnergyShow(bool json) char voltage_chr[Energy.phase_count][FLOATSZ]; char current_chr[Energy.phase_count][FLOATSZ]; char active_power_chr[Energy.phase_count][FLOATSZ]; -#ifdef SDM630_IMPORT +#if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) char import_active_chr[Energy.phase_count][FLOATSZ]; -#endif // SDM630_IMPORT +#endif // SDM630_IMPORT || SDM72_IMPEXP char export_active_chr[Energy.phase_count][FLOATSZ]; for (uint32_t i = 0; i < Energy.phase_count; i++) { dtostrfd(Energy.voltage[i], Settings.flag2.voltage_resolution, voltage_chr[i]); dtostrfd(Energy.current[i], Settings.flag2.current_resolution, current_chr[i]); dtostrfd(Energy.active_power[i], Settings.flag2.wattage_resolution, active_power_chr[i]); -#ifdef SDM630_IMPORT +#if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) dtostrfd(Energy.import_active[i], Settings.flag2.energy_resolution, import_active_chr[i]); -#endif // SDM630_IMPORT +#endif // SDM630_IMPORT || SDM72_IMPEXP dtostrfd(Energy.export_active[i], Settings.flag2.energy_resolution, export_active_chr[i]); } @@ -1040,7 +1040,7 @@ void EnergyShow(bool json) energy_yesterday_chr, energy_daily_chr); - #ifdef SDM630_IMPORT + #if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) if (!isnan(Energy.import_active[0])) { ResponseAppend_P(PSTR(",\"" D_JSON_IMPORT_ACTIVE "\":%s"), EnergyFormat(value_chr, import_active_chr[0], json)); @@ -1049,7 +1049,7 @@ void EnergyShow(bool json) EnergyFormatIndex(value_chr, energy_return_chr[0], json, 2)); } } -#endif // SDM630_IMPORT +#endif // SDM630_IMPORT || SDM72_IMPEXP if (!isnan(Energy.export_active[0])) { ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"), @@ -1152,11 +1152,11 @@ void EnergyShow(bool json) if (!isnan(Energy.export_active[0])) { WSContentSend_PD(HTTP_ENERGY_SNS3, EnergyFormat(value_chr, export_active_chr[0], json)); } -#ifdef SDM630_IMPORT +#if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) if (!isnan(Energy.import_active[0])) { WSContentSend_PD(HTTP_ENERGY_SNS4, EnergyFormat(value_chr, import_active_chr[0], json)); } -#endif // SDM630_IMPORT +#endif // SDM630_IMPORT || SDM72_IMPEXP XnrgCall(FUNC_WEB_SENSOR); #endif // USE_WEBSERVER diff --git a/tasmota/xnrg_18_sdm72.ino b/tasmota/xnrg_18_sdm72.ino new file mode 100644 index 000000000000..0da11cba3b08 --- /dev/null +++ b/tasmota/xnrg_18_sdm72.ino @@ -0,0 +1,210 @@ +/* + xnrg_18_sdm72.ino - Eastron SDM72D-M Modbus energy meter support for Tasmota + + Copyright (C) 2021 Gennaro Tortone, Theo Arends and Norbert Richter + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_ENERGY_SENSOR +#ifdef USE_SDM72 +/*********************************************************************************************\ + * Eastron SDM72 Modbus energy meter +\*********************************************************************************************/ + +#define XNRG_18 18 + +// can be user defined in my_user_config.h +#ifndef SDM72_SPEED + #define SDM72_SPEED 9600 // default SDM72 Modbus address +#endif +// can be user defined in my_user_config.h +#ifndef SDM72_ADDR + #define SDM72_ADDR 1 // default SDM72 Modbus address +#endif + +#include +TasmotaModbus *Sdm72Modbus; + +const uint16_t sdm72_register[] { + 0x0034, // 0 SDM72D_POWER [W] + 0x0156, // 3 SDM72D_TOTAL_ACTIVE [kWh] +#ifdef SDM72_IMPEXP + 0x0500, // 1 SDM72D_IMPORT_POWER [W] + 0x0502, // 2 SDM72D_EXPORT_POWER [W] + 0x0048, // 4 SDM72D_IMPORT_ACTIVE [kWh] + 0x004A // 5 SDM72D_EXPORT_ACTIVE [kWh] +#endif // SDM72_IMPEXP +}; + +struct SDM72 { + float total_active = NAN; +#ifdef SDM72_IMPEXP + float import_power = 0; + float export_power = 0; + float import_active = 0; +#endif // SDM72_IMPEXP + uint8_t read_state = 0; + uint8_t send_retry = 0; +} Sdm72; + +/*********************************************************************************************/ + +void Sdm72Every250ms(void) +{ + bool data_ready = Sdm72Modbus->ReceiveReady(); + + if (data_ready) { + uint8_t buffer[14]; // At least 5 + (2 * 2) = 9 + + uint32_t error = Sdm72Modbus->ReceiveBuffer(buffer, 2); + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Sdm72Modbus->ReceiveCount()); + + if (error) { + AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: SDM72 error %d"), error); + } else { + Energy.data_valid[0] = 0; + + float value; + ((uint8_t*)&value)[3] = buffer[3]; // Get float values + ((uint8_t*)&value)[2] = buffer[4]; + ((uint8_t*)&value)[1] = buffer[5]; + ((uint8_t*)&value)[0] = buffer[6]; + + switch(Sdm72.read_state) { + case 0: + Energy.active_power[0] = value; // W + break; + + case 1: + Sdm72.total_active = value; // kWh + break; + +#ifdef SDM72_IMPEXP + case 2: + Sdm72.import_power = value; // W + break; + + case 3: + Sdm72.export_power = value; // W + break; + + case 4: + Energy.import_active[0] = value; // kWh + break; + + case 5: + Energy.export_active[0] = value; // kWh + break; +#endif // SDM72_IMPEXP + } + + ++Sdm72.read_state %= ARRAY_SIZE(sdm72_register); + if (0 == Sdm72.read_state && !isnan(Sdm72.total_active)) { + EnergyUpdateTotal(Sdm72.total_active, true); + } + } + } // end data ready + + if (0 == Sdm72.send_retry || data_ready) { + Sdm72.send_retry = 5; + Sdm72Modbus->Send(SDM72_ADDR, 0x04, sdm72_register[Sdm72.read_state], 2); + } else { + Sdm72.send_retry--; + } +} + +void Sdm72SnsInit(void) +{ + Sdm72Modbus = new TasmotaModbus(Pin(GPIO_SDM72_RX), Pin(GPIO_SDM72_TX)); + uint8_t result = Sdm72Modbus->Begin(SDM72_SPEED); + if (result) { + if (2 == result) { + ClaimSerial(); + } + } else { + TasmotaGlobal.energy_driver = ENERGY_NONE; + } +} + +void Sdm72DrvInit(void) +{ + if (PinUsed(GPIO_SDM72_RX) && PinUsed(GPIO_SDM72_TX)) { + Energy.voltage_available = false; + Energy.current_available = false; + TasmotaGlobal.energy_driver = XNRG_18; + } +} + +#ifdef USE_WEBSERVER +#ifdef SDM72_IMPEXP +const char HTTP_ENERGY_SDM72[] PROGMEM = + "{s}" D_EXPORT_POWER "{m}%*_f " D_UNIT_WATT "{e}" + "{s}" D_IMPORT_POWER "{m}%*_f " D_UNIT_WATT "{e}"; +#endif // SDM72_IMPEXP +#endif // USE_WEBSERVER + +void Sdm72Show(bool json) +{ + if (isnan(Sdm72.total_active)) { return; } + + if (json) { +#ifdef SDM72_IMPEXP + ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_POWER "\":%*_f,\"" D_JSON_IMPORT_POWER "\":%*_f"), + Settings.flag2.wattage_resolution, &Sdm72.export_power, + Settings.flag2.wattage_resolution, &Sdm72.import_power); +#endif // SDM72_IMPEXP +#ifdef USE_WEBSERVER + } else { +#ifdef SDM72_IMPEXP + WSContentSend_PD(HTTP_ENERGY_SDM72, + Settings.flag2.wattage_resolution, &Sdm72.export_power, + Settings.flag2.wattage_resolution, &Sdm72.import_power); +#endif // SDM72_IMPEXP +#endif // USE_WEBSERVER + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xnrg18(uint8_t function) +{ + bool result = false; + + switch (function) { + case FUNC_EVERY_250_MSECOND: + Sdm72Every250ms(); + break; + case FUNC_JSON_APPEND: + Sdm72Show(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + Sdm72Show(0); + break; +#endif // USE_WEBSERVER + case FUNC_INIT: + Sdm72SnsInit(); + break; + case FUNC_PRE_INIT: + Sdm72DrvInit(); + break; + } + return result; +} + +#endif // USE_SDM72 +#endif // USE_ENERGY_SENSOR diff --git a/tools/decode-status.py b/tools/decode-status.py index 040ae94d48c9..995d0e111295 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -245,7 +245,7 @@ "USE_DISPLAY_ILI9488","USE_DISPLAY_SSD1351","USE_DISPLAY_RA8876","USE_DISPLAY_ST7789", "USE_DISPLAY_SSD1331","USE_UFILESYS","USE_TIMEPROP","USE_PID", "USE_BS814A2","USE_SEESAW_SOIL","USE_WIEGAND","USE_NEOPOOL", - "USE_TOF10120","","","" + "USE_TOF10120","USE_SDM72","","" ],[ "","","","", "","","","",