From 88b296cf837f1315acba02499aff8f6ec5bc2f29 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 15 Jan 2022 15:02:45 +0100 Subject: [PATCH] Support for Eastron SDM230 Add support for Eastron SDM230 modBus energy meter (#13443) --- BUILDS.md | 1 + CHANGELOG.md | 2 +- RELEASENOTES.md | 1 + tasmota/support_features.ino | 10 +++++----- tasmota/xnrg_21_sdm230.ino | 18 +++++++++--------- tools/decode-status.py | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/BUILDS.md b/BUILDS.md index 975e34d24..b1154b6c1 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -76,6 +76,7 @@ Note: `minimal` variant is not listed as it shouldn't be used outside of the [up | USE_MCP39F501 | x | x / - | x | x | - | - | | USE_SDM72 | - | - / x | - | x | - | - | | USE_SDM120 | - | - / x | - | x | - | - | +| USE_SDM230 | - | - / x | - | - | - | - | | USE_SDM630 | - | - / x | - | x | - | - | | USE_DDS2382 | - | - / x | - | x | - | - | | USE_DDSU666 | - | - / x | - | x | - | - | diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6a9df59..049bd99d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development -- added support for Eastron SDM230 ModBus ## [2022.01.2] ### Added - Tasmota favicon to webbrowser tab (#14322) - Commands for ESP32 ethernet configuration ``EthIpAddress``, ``EthGateway``, ``EthSubnetmask``, ``EthDnsServer1`` and ``EthDnsServer2`` (#14385) +- Support for Eastron SDM230 modBus energy meter (#13443) ### Changed - IRremoteESP8266 library from v2.8.0 to v2.8.1 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 6b335b460..c80799e0a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -105,6 +105,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - Command ``SSerialConfig `` to change Serial Bridge configuration - Command ``SspmMap 2,1,..`` to map Sonoff SPM scanned module to physical module [#14281](https://github.com/arendst/Tasmota/issues/14281) - Commands for ESP32 ethernet configuration ``EthIpAddress``, ``EthGateway``, ``EthSubnetmask``, ``EthDnsServer1`` and ``EthDnsServer2`` [#14385](https://github.com/arendst/Tasmota/issues/14385) +- Support for Eastron SDM230 modBus energy meter [#13443](https://github.com/arendst/Tasmota/issues/13443) - PWM Dimmer two button support [#13993](https://github.com/arendst/Tasmota/issues/13993) - Support for Linkind dimmer as GPIO ``Option A6`` [#14004](https://github.com/arendst/Tasmota/issues/14004) - DDP schemes for light and WS2812 [#14017](https://github.com/arendst/Tasmota/issues/14017) diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 5b5eaf671..54d7e16d3 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -741,7 +741,7 @@ void ResponseAppendFeatures(void) feature8 |= 0x00000010; // xdrv_56_BM8563_RTC.ino #endif #if defined(USE_ENERGY_SENSOR) && defined(USE_ENERGY_DUMMY) - feature8 |= 0x00000020; // xnrg_20_dummy.ino + feature8 |= 0x00000020; // xnrg_30_dummy.ino #endif #if defined(USE_I2C) && defined(USE_AM2320) feature8 |= 0x00000040; // xsns_88_am2320.ino @@ -749,7 +749,6 @@ void ResponseAppendFeatures(void) #if defined(USE_I2C) && defined(USE_T67XX) feature8 |= 0x00000080; // xsns_89_t67xx.ino #endif - #if defined(USE_SPI) && defined(USE_MCP2515) feature8 |= 0x00000100; // xsns_87_mcp2515.ino #endif @@ -774,7 +773,6 @@ void ResponseAppendFeatures(void) #if defined(USE_I2C) && defined(USE_HM330X) feature8 |= 0x00008000; // xsns_93_hm330x.ino #endif - #if defined(USE_I2C) && defined(USE_HDC2010) feature8 |= 0x00010000; // xsns_94_hdc2010.ino #endif @@ -782,12 +780,14 @@ void ResponseAppendFeatures(void) feature8 |= 0x00020000; // xlgt_07_lsc_mcsl.ino #endif #ifdef USE_SONOFF_SPM - feature8 |= 0x00040000; + feature8 |= 0x00040000; // xdrv_86_esp32_sonoff_spm.ino #endif #ifdef USE_SHIFT595 feature8 |= 0x00080000; // xdrv_60_shift595.ino #endif -// feature8 |= 0x00100000; +#ifdef USE_SDM230 + feature8 |= 0x00100000; // xnrg_21_sdm230.ino +#endif // feature8 |= 0x00200000; // feature8 |= 0x00400000; // feature8 |= 0x00800000; diff --git a/tasmota/xnrg_21_sdm230.ino b/tasmota/xnrg_21_sdm230.ino index 9cdbdea81..e7b28068a 100644 --- a/tasmota/xnrg_21_sdm230.ino +++ b/tasmota/xnrg_21_sdm230.ino @@ -1,7 +1,7 @@ /* - xnrg_08_sdm230.ino - Eastron SDM230-Modbus energy meter support for Tasmota + xnrg_21_sdm230.ino - Eastron SDM230-Modbus energy meter support for Tasmota - Copyright (C) 2021 Gennaro Tortone and Theo Arends + Copyright (C) 2022 dad401 and Theo Arends 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 @@ -24,7 +24,7 @@ * * Based on: existing tasmota drivers for SDM120 and SDM630, * https://github.com/reaper7/SDM_Energy_Meter and https://github.com/nmakel/sdm_modbus - + * manuals can be found here: * German: https://bg-etech.de/download/manual/SDM230-Modbus.pdf * English: https://www.eastroneurope.com/images/uploads/products/manuals/SDM230_Sereis_Manual.pdf @@ -52,7 +52,7 @@ const uint16_t sdm230_start_addresses[] { 0x000C, // SDM230_POWER (Active) [W] 0x0012, // SDM230_POWER (Apparent) G [VA] 0x0018, // SDM230_POWER (Reactive) [VAr] - 0x001E, // SDM230_POWER_FACTOR + 0x001E, // SDM230_POWER_FACTOR 0x0046, // SDM230_FREQUENCY [Hz] 0X0048, // SDM230_IMPORT_ACTIVE [kWh] 0X004A, // SDM230_EXPORT_ACTIVE [kWh] @@ -152,17 +152,17 @@ void SDM230Every250ms(void) Energy.export_active[0] = value; // 478.492 kWh break; - #ifdef SDM230_MORE_REGS + #ifdef SDM230_MORE_REGS case 9: Sdm230.phase_angle = value; // 0.00 Deg break; case 10: - Sdm230.maximum_total_demand_power_active = value; + Sdm230.maximum_total_demand_power_active = value; break; case 11: - Sdm230.resettable_total_energy = value; + Sdm230.resettable_total_energy = value; break; #endif // SDM230_MORE_REGS } @@ -170,9 +170,9 @@ void SDM230Every250ms(void) Sdm230.read_state++; if (sizeof(sdm230_start_addresses)/2 == Sdm230.read_state) { Sdm230.read_state = 0; - EnergyUpdateTotal(); // update every cycle after all registers have been read + EnergyUpdateTotal(); // update every cycle after all registers have been read } - + } } // end data ready diff --git a/tools/decode-status.py b/tools/decode-status.py index baea5dc94..4d1ebfdb1 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -262,7 +262,7 @@ a_features = [[ "USE_MCP2515","USE_TASMESH","USE_WIFI_RANGE_EXTENDER","USE_INFLUXDB", "USE_HRG15","USE_VINDRIKTNING","USE_SCD40","USE_HM330X", "USE_HDC2010","USE_LSC_MCSL","USE_SONOFF_SPM","USE_SHIFT595", - "","","","", + "USE_SDM230","","","", "","","","", "","","","" ]] @@ -292,7 +292,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20211205 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20220115 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))