From ba55d67cbc27fcd17d55b11a2e5b4dbfcf464807 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 23 Oct 2021 13:54:03 +0200 Subject: [PATCH] changed: BUILDS.md changed: CHANGELOG.md changed: tasmota/language/de_DE.h changed: tasmota/language/en_GB.h open/todo: update all other localization files changed: tasmota/my_user_config.h changed: tasmota/support_features.ino changed: tasmota/tasmota_configurations.h changed: tasmota/tasmota_configurations_ESP32.h changed: tasmota/tasmota_template.h changed: tasmota/tasmota_template_legacy.h changed: tasmota/xdrv_03_energy.ino new file: tasmota/xnrg_21_sdm230.ino added support (POC) for Eastron SDM230 ModBus (based on existing drivers SDM120 and SDM630) - suggestion for future versions: use the same pin names for all SDM(72|120|220|230|630) drivers, e.g.: GPIO_SDMxxx_TX and GPIO_SDMxxx_RX and integrate all drivers into one (xnrg_xx_SDM-ModBus.ino) --- BUILDS.md | 235 ++++++++++++++++++++++ CHANGELOG.md | 3 + tasmota/language/de_DE.h | 5 +- tasmota/language/en_GB.h | 5 +- tasmota/my_user_config.h | 3 + tasmota/support_features.ino | 3 + tasmota/tasmota_configurations.h | 6 + tasmota/tasmota_configurations_ESP32.h | 2 +- tasmota/tasmota_template.h | 13 ++ tasmota/tasmota_template_legacy.h | 4 + tasmota/xdrv_03_energy.ino | 4 +- tasmota/xnrg_21_sdm230.ino | 261 +++++++++++++++++++++++++ 12 files changed, 539 insertions(+), 5 deletions(-) create mode 100644 tasmota/xnrg_21_sdm230.ino diff --git a/BUILDS.md b/BUILDS.md index 975e34d24..26f10c1b7 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -4,6 +4,7 @@ ESP8266 / ESP32 l = lite, t = tasmota, k = knx, s = sensors, i = ir, d = display +<<<<<<< HEAD Note: `minimal` variant is not listed as it shouldn't be used outside of the [upgrading](https://tasmota.github.io/docs/Upgrading/) process. | Feature or Sensor | l | t | k | s | i | d | Remarks @@ -236,3 +237,237 @@ Note: `minimal` variant is not listed as it shouldn't be used outside of the [up | USE_ETHERNET | | / - | | | | | | USE_I2S_AUDIO | | / - | | | | | | USE_TTGO_WATCH | | / - | | | | | +======= +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +|-----------------------|---|---|-------|---|---|---|---|-------- +| MY_LANGUAGE en_GB | x | x | x / x | x | x | x | x | +| USE_UFILESYS | - | - | - / x | - | - | - | - | +| USE_ARDUINO_OTA | - | - | - / - | - | - | - | - | +| USE_DOMOTICZ | - | - | x / x | x | x | x | - | +| USE_HOME_ASSISTANT | - | - | x / x | x | x | x | - | +| USE_MQTT_TLS | - | - | - / - | - | - | - | - | +| USE_MQTT_TLS_CA_CERT | - | - | - / - | - | - | - | - | +| USE_MQTT_AWS_IOT | - | - | - / - | - | - | - | - | +| USE_4K_RSA | - | - | - / - | - | - | - | - | +| USE_TELEGRAM | - | - | - / - | - | - | - | - | +| USE_KNX | - | - | - / x | x | - | - | - | +| USE_WEBSERVER | x | x | x / x | x | x | x | x | +| USE_JAVASCRIPT_ES6 | - | - | - / - | - | - | - | - | +| USE_WEBSEND_RESPONSE | - | - | - / - | - | - | - | - | +| USE_EMULATION_HUE | - | x | x / x | - | x | - | - | +| USE_EMULATION_WEMO | - | x | x / x | - | x | - | - | +| USE_DISCOVERY | - | - | - / - | - | - | - | - | +| WEBSERVER_ADVERTISE | - | - | x / - | x | - | - | x | +| MQTT_HOST_DISCOVERY | - | - | - / - | - | - | - | - | +| USE_TIMERS | - | x | x / x | x | x | x | x | +| USE_TIMERS_WEB | - | x | x / x | x | x | x | x | +| USE_SUNRISE | - | x | x / x | x | x | x | x | +| USE_RULES | - | x | x / x | x | x | x | x | +| USE_SCRIPT | - | - | - / - | - | - | - | - | +| USE_EXPRESSION | - | - | - / - | - | - | - | - | +| SUPPORT_IF_STATEMENT | - | - | - / - | - | - | - | - | +| USE_HOTPLUG | - | - | - / - | - | - | - | - | +| USE_PROMETHEUS | - | - | - / - | - | - | - | - | +| USE_PING | - | - | - / - | - | - | - | - | +| | | | | | | | | +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +| ROTARY_V1 | - | - | x / x | - | x | - | - | +| USE_SONOFF_RF | - | - | x / - | x | x | - | - | +| USE_RF_FLASH | - | - | x / - | x | x | - | - | +| USE_SONOFF_SC | - | - | x / - | x | x | - | - | +| USE_TUYA_MCU | - | x | x / - | x | x | - | x | +| USE_ARMTRONIX_DIMMERS | - | - | x / - | x | - | - | - | +| USE_PS_16_DZ | - | - | x / - | x | - | - | - | +| USE_SONOFF_IFAN | - | - | x / - | x | - | - | - | +| USE_BUZZER | - | - | x / x | x | x | - | - | +| USE_ARILUX_RF | - | - | x / - | x | - | - | - | +| USE_SHUTTER | - | - | x / x | x | - | - | - | +| USE_DEEPSLEEP | - | - | x / x | - | x | - | - | +| USE_EXS_DIMMER | - | - | x / - | x | - | - | - | +| USE_DEVICE_GROUPS | - | - | x / x | - | - | - | - | +| USE_PWM_DIMMER | - | - | x / - | x | - | - | - | +| USE_KEELOQ | - | - | - / - | - | - | - | - | +| USE_SONOFF_D1 | - | - | x / - | x | - | - | - | +| USE_SHELLY_DIMMER | - | - | x / - | - | - | - | - | +| USE_AC_ZERO_CROSS_DIMMER | - | - | x / x | x | x | x | x | +| | | | | | | | | +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +| USE_LIGHT | - | x | x / x | x | x | x | x | +| USE_WS2812 | - | - | x / x | x | x | - | x | +| USE_WS2812_DMA | - | - | - / - | - | - | - | - | +| USE_MY92X1 | - | - | x / - | x | x | - | x | +| USE_SM16716 | - | - | x / - | x | x | - | x | +| USE_SM2135 | - | - | x / - | x | x | - | x | +| USE_SONOFF_L1 | - | - | x / - | x | x | - | x | +| USE_ELECTRIQ_MOODL | - | - | x / - | x | x | - | x | +| | | | | | | | | +| USE_ENERGY_SENSOR | - | x | x / x | x | x | - | - | +| USE_ENERGY_DUMMY | - | x | x / x | x | x | - | - | +| USE_PZEM004T | - | - | x / x | x | x | - | - | +| USE_PZEM_AC | - | - | x / x | x | x | - | - | +| USE_PZEM_DC | - | - | x / x | x | x | - | - | +| USE_MCP39F501 | - | x | x / - | x | x | - | - | +| USE_SDM72 | - | - | - / x | - | x | - | - | +| USE_SDM120 | - | - | - / x | - | x | - | - | +| USE_SDM630 | - | - | - / x | - | x | - | - | +| USE_DDS2382 | - | - | - / x | - | x | - | - | +| USE_DDSU666 | - | - | - / x | - | x | - | - | +| USE_SOLAX_X1 | - | - | - / - | - | - | - | - | +| USE_LE01MR | - | - | - / - | - | - | - | - | +| USE_BL09XX | - | x | x / x | x | x | - | - | +| USE_TELEINFO | - | - | - / - | - | - | - | - | +| USE_IEM3000 | - | - | - / - | - | - | - | - | +| USE_WE517 | - | - | - / - | - | - | - | - | +| | | | | | | | | +| USE_ADC_VCC | x | x | - / - | - | - | x | - | +| USE_COUNTER | - | - | x / x | x | x | - | x | +| USE_DS18x20 | - | - | x / x | x | x | - | x | +| USE_DHT | - | - | x / x | x | x | - | x | +| USE_MAX31855 | - | - | - / x | - | x | - | - | +| USE_MAX31865 | - | - | - / - | - | - | - | - | +| USE_THERMOSTAT | - | - | - / - | - | - | - | - | +| USE_LMT01 | - | - | - / x | - | x | - | - | +| | | | | | | | | +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +| USE_I2C | - | - | x / x | x | x | - | x | +| USE_SHT | - | - | - / x | - | x | - | - | +| USE_HTU | - | - | - / x | - | x | - | - | +| USE_BMP | - | - | - / x | - | x | - | - | +| USE_BME680 | - | - | - / x | - | x | - | - | +| USE_BH1750 | - | - | - / x | - | x | - | - | +| USE_VEML6070 | - | - | - / x | - | x | - | - | +| USE_ADS1115 | - | - | - / x | - | x | - | - | +| USE_INA219 | - | - | - / x | - | x | - | - | +| USE_INA226 | - | - | - / - | - | - | - | - | +| USE_SHT3X | - | - | - / x | - | x | - | - | +| USE_TSL2561 | - | - | - / - | - | - | - | - | +| USE_TSL2591 | - | - | - / - | - | - | - | - | +| USE_MGS | - | - | - / x | - | x | - | - | +| USE_SGP30 | - | - | - / x | - | x | - | - | +| USE_SI1145 | - | - | - / - | - | - | - | - | +| USE_LM75AD | - | - | - / x | - | x | - | - | +| USE_APDS9960 | - | - | - / - | - | - | - | - | +| USE_MCP230xx | - | - | - / - | - | - | - | - | +| USE_PCA9685 | - | - | - / - | - | - | - | - | +| USE_MPR121 | - | - | - / - | - | - | - | - | +| USE_CCS811 | - | - | - / - | - | x | - | - | +| USE_CCS811_V2 | - | - | - / x | - | - | - | - | +| USE_MPU6050 | - | - | - / - | - | - | - | - | +| USE_DS3231 | - | - | - / - | - | - | - | - | +| USE_MGC3130 | - | - | - / - | - | - | - | - | +| USE_MAX44009 | - | - | - / - | - | - | - | - | +| USE_SCD30 | - | - | - / x | - | x | - | - | +| USE_SCD40 | - | - | - / x | - | - | - | - | +| USE_SPS30 | - | - | - / - | - | - | - | - | +| USE_ADE7953 | - | - | x / x | x | x | - | x | +| USE_VL53L0X | - | - | - / x | - | x | - | - | +| USE_MLX90614 | - | - | - / - | - | - | - | - | +| USE_CHIRP | - | - | - / - | - | - | - | - | +| USE_PAJ7620 | - | - | - / - | - | - | - | - | +| USE_PCF8574 | - | - | - / - | - | - | - | - | +| | | | | | | | | +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +| USE_HIH6 | - | - | - / x | - | x | - | - | +| USE_DHT12 | - | - | - / x | - | x | - | - | +| USE_DS1624 | - | - | - / x | - | x | - | - | +| USE_AHT1x | - | - | - / - | - | - | - | - | +| USE_HDC1080 | - | - | - / - | - | - | - | - | +| USE_WEMOS_MOTOR_V1 | - | - | - / x | - | x | - | - | +| USE_IAQ | - | - | - / x | - | x | - | - | +| USE_AS3935 | - | - | - / x | - | x | - | - | +| USE_VEML6075 | - | - | - / - | - | - | - | - | +| USE_VEML7700 | - | - | - / - | - | - | - | - | +| USE_MCP9808 | - | - | - / - | - | - | - | - | +| USE_HP303B | - | - | - / - | - | - | - | - | +| USE_EZOCO2 | - | - | - / - | - | - | - | - | +| USE_EZODO | - | - | - / - | - | - | - | - | +| USE_EZOEC | - | - | - / - | - | - | - | - | +| USE_EZOFLO | - | - | - / - | - | - | - | - | +| USE_EZOHUM | - | - | - / - | - | - | - | - | +| USE_EZOO2 | - | - | - / - | - | - | - | - | +| USE_EZOORP | - | - | - / - | - | - | - | - | +| USE_EZOPH | - | - | - / - | - | - | - | - | +| USE_EZOPMP | - | - | - / - | - | - | - | - | +| USE_EZOPRS | - | - | - / - | - | - | - | - | +| USE_EZORGB | - | - | - / - | - | - | - | - | +| USE_EZORTD | - | - | - / - | - | - | - | - | +| USE_SEESAW_SOIL | - | - | - / - | - | - | - | - | +| USE_TOF10120 | - | - | - / - | - | - | - | - | +| USE_AM2320 | - | - | - / - | - | - | - | - | +| USE_T67XX | - | - | - / - | - | - | - | - | +| USE_HM330X | - | - | - / - | - | - | - | - | +| | | | | | | | | +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +| USE_SPI | - | - | - / - | - | - | - | x | +| USE_RC522 | - | - | - / - | - | - | - | - | +| USE_MHZ19 | - | - | - / x | - | x | - | - | +| USE_SENSEAIR | - | - | - / x | - | x | - | - | +| USE_PMS5003 | - | - | - / x | - | x | - | - | +| USE_NOVA_SDS | - | - | - / x | - | x | - | - | +| USE_HPMA | - | - | - / x | - | x | - | - | +| USE_SERIAL_BRIDGE | - | - | x / x | x | x | - | x | +| USE_MP3_PLAYER | - | - | - / x | - | x | - | - | +| USE_AZ7798 | - | - | - / - | - | - | - | - | +| USE_PN532_HSU | - | - | - / x | - | x | - | - | +| USE_RDM6300 | - | - | - / x | - | x | - | - | +| USE_IBEACON | - | - | - / x | - | x | - | - | +| USE_GPS | - | - | - / - | - | - | - | - | +| USE_HM10 | - | - | - / - | - | x | - | - | +| USE_HRXL | - | - | - / x | - | x | - | - | +| USE_TASMOTA_CLIENT | - | - | - / - | - | - | - | - | +| USE_OPENTHERM | - | - | - / - | - | - | - | - | +| USE_MIEL_HVAC | - | - | - / - | - | - | - | - | +| USE_PROJECTOR_CTRL | - | - | - / - | - | - | - | - | +| USE_AS608 | - | - | - / - | - | - | - | - | +| USE_TCP_BRIDGE | - | - | - / - | - | - | - | - | zbbridge +| | | | | | | | | +| USE_NRF24 | - | - | - / - | - | - | - | - | +| USE_MIBLE | - | - | - / - | - | - | - | - | +| USE_ZIGBEE | - | - | - / - | - | - | - | - | +| USE_ZIGBEE_ZNP | - | - | - / - | - | - | - | - | +| USE_ZIGBEE_EZSP | - | - | - / - | - | - | - | - | Sonoff ZbBridge +| | | | | | | | | +| USE_IR_REMOTE | - | - | x / - | x | x | x | x | +| USE_IR_RECEIVE | - | - | x / - | x | x | x | x | +| USE_IR_REMOTE_FULL | - | - | - / - | - | - | x | - | Enable ALL protocols +| | | | | | | | | +| USE_SR04 | - | - | - / - | - | x | - | - | +| USE_DYP | - | - | - / - | - | - | - | - | +| USE_TM1638 | - | - | - / x | - | x | - | - | +| USE_HX711 | - | - | - / x | - | x | - | - | +| USE_TX2x_WIND_SENSOR | - | - | - / - | - | - | - | - | +| USE_WINDMETER | - | - | - / - | - | - | - | - | +| USE_RC_SWITCH | - | - | - / x | - | x | - | - | +| USE_RF_SENSOR | - | - | - / x | - | x | - | - | AlectoV2 only +| USE_HRE | - | - | - / x | - | x | - | - | +| USE_A4988_STEPPER | - | - | - / - | - | - | - | - | +| USE_NEOPOOL | - | - | - / - | - | - | - | - | +| | | | | | | | | +| Feature or Sensor | m | l | t | k | s | i | d | Remarks +| USE_DISPLAY | - | - | - / - | - | - | - | x | +| USE_DISPLAY_LCD | - | - | - / - | - | - | - | x | +| USE_DISPLAY_SSD1306 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_MATRIX | - | - | - / - | - | - | - | x | +| USE_DISPLAY_SH1106 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_ILI9341 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_EPAPER_29 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_EPAPER_42 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_ILI9488 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_SSD1351 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_RA8876 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_ST7789 | - | - | - / - | - | - | - | x | +| USE_DISPLAY_TM1637 | - | - | - / - | - | - | - | x | +| | | | | | | | | +| USE_FT5206 | - | - | - / - | - | - | - | - | +| USE_FTC532 | - | - | - / - | - | - | - | - | +| USE_BS814A2 | - | - | - / - | - | - | - | - | +| | | | | | | | | +| ESP32 Feature | m | l | t | k | s | i | d | Remarks +| USE_HALLEFFECT | | | / x | | | | | +| USE_MI_ESP32 | | | / x | | | | | See SetOption115 +| USE_IBEACON_ESP32 | | | / - | | | | | +| USE_WEBCAM | | | / - | | | | | +| USE_ETHERNET | | | / - | | | | | +| USE_I2S_AUDIO | | | / - | | | | | +| USE_TTGO_WATCH | | | / - | | | | | +>>>>>>> changed: BUILDS.md diff --git a/CHANGELOG.md b/CHANGELOG.md index e118a4994..f58774b26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development +- added support (POC) for Eastron SDM230 ModBus (based on existing drivers SDM120 and SDM630) - suggestion for future versions: +use the same pin names for all SDM(72|120|220|230|630) drivers, e.g.: GPIO_SDMxxx_TX and GPIO_SDMxxx_RX and integrate +all drivers into one (xnrg_xx_SDM-ModBus.ino) ## [2022.01.2] ### Added diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index 5dc9f72dd..dd5ddd31d 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -663,6 +663,8 @@ #define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" +#define D_SENSOR_SDM230_TX "SDM230 Tx" +#define D_SENSOR_SDM230_RX "SDM230 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" #define D_SENSOR_WE517_TX "WE517 Tx" @@ -899,7 +901,7 @@ #define D_OUT_OF_RANGE "Außerhalb Bereich" #define D_SENSOR_DETECTED "erkannt" -//SDM220, SDM120, SDM72, LE01MR +//SDM220, SDM120, SDM72, LE01MR, SDM230 #define D_EXPORT_POWER "Exportiere Leistung" #define D_IMPORT_POWER "Importiere Leistung" #define D_PHASE_ANGLE "Phasenwinkel" @@ -911,6 +913,7 @@ #define D_UNIT_KWARH "kVArh" #define D_UNIT_ANGLE "Grad" #define D_TOTAL_ACTIVE "Total Wirk" +#define D_RESETTABLE_TOTAL_ACTIVE "Total Wirk (RST)" //SOLAXX1 #define D_PV1_VOLTAGE "PV1 Spannung" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index 39d0457cb..20c2b8107 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -663,6 +663,8 @@ #define D_SENSOR_SDM72_RX "SDM72 Rx" #define D_SENSOR_SDM120_TX "SDMx20 Tx" #define D_SENSOR_SDM120_RX "SDMx20 Rx" +#define D_SENSOR_SDM230_TX "SDM230 Tx" +#define D_SENSOR_SDM230_RX "SDM230 Rx" #define D_SENSOR_SDM630_TX "SDM630 Tx" #define D_SENSOR_SDM630_RX "SDM630 Rx" #define D_SENSOR_WE517_TX "WE517 Tx" @@ -899,7 +901,7 @@ #define D_OUT_OF_RANGE "Out of Range" #define D_SENSOR_DETECTED "detected" -//SDM220, SDM120, SDM72, LE01MR +//SDM220, SDM120, SDM72, LE01MR, SDM230 #define D_EXPORT_POWER "Export Power" #define D_IMPORT_POWER "Import Power" #define D_PHASE_ANGLE "Phase Angle" @@ -911,6 +913,7 @@ #define D_UNIT_KWARH "kVArh" #define D_UNIT_ANGLE "Deg" #define D_TOTAL_ACTIVE "Total Active" +#define D_RESETTABLE_TOTAL_ACTIVE "Total Active (RST)" //SOLAXX1 #define D_PV1_VOLTAGE "PV1 Voltage" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 7e4afb25d..371089801 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -781,6 +781,9 @@ // #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_SDM230 // Add support for Eastron SDM230-Modbus energy monitor (+?? code) + #define SDM230_SPEED 2400 // SDM230-Modbus RS485 serial speed (default: 9600 baud) +// #define SDM230_IMPORT // Show import active energy in MQTT and Web (+0k3 code) //#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy monitor (+0k6 code) #define SDM630_SPEED 9600 // SDM630-Modbus RS485 serial speed (default: 9600 baud) // #define SDM630_IMPORT // Show import active energy in MQTT and Web (+0k3 code) diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 5b5eaf671..70f1f073a 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -320,6 +320,9 @@ void ResponseAppendFeatures(void) #endif #ifdef USE_TM1638 feature3 |= 0x80000000; // xsns_28_tm1638.ino +#endif +#if defined(USE_ENERGY_SENSOR) && defined(USE_SDM230) + feature3 |= 0x100000000; // xnrg_21_sdm230.ino #endif } diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 18bbd4d18..ba373b4f1 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -199,6 +199,7 @@ #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_SDM230 // Add support for Eastron SDM230-Modbus energy monitor (+?? 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) #define USE_DDSU666 // Add support for Chint DDSU666 Modbus energy monitor (+0k6 code) @@ -303,6 +304,7 @@ #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_SDM230 // Disable support for Eastron SDM230-Modbus energy monitor (+?? code) #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) #undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code) @@ -411,6 +413,7 @@ #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_SDM230 // Disable support for Eastron SDM230-Modbus energy monitor (+?? code) #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) #undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code) @@ -586,6 +589,7 @@ #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_SDM230 // Disable support for Eastron SDM230-Modbus energy monitor (+?? code) #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) #undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code) @@ -727,6 +731,7 @@ //#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_SDM230 // Disable support for Eastron SDM230-Modbus energy monitor (+?? code) #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) #undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code) @@ -870,6 +875,7 @@ #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_SDM230 // Disable support for Eastron SDM230-Modbus energy monitor (+?? code) #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) #undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code) diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h index 7062dd38a..b9296e2a4 100644 --- a/tasmota/tasmota_configurations_ESP32.h +++ b/tasmota/tasmota_configurations_ESP32.h @@ -1,4 +1,3 @@ -/* tasmota_configurations_ESP32.h - ESP32 only Configurations for Tasmota Copyright (C) 2021 Theo Arends @@ -517,6 +516,7 @@ #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_SDM230 // Add support for Eastron SDM230-Modbus energy monitor (+?? 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) #define USE_DDSU666 // Add support for Chint DDSU666 Modbus energy monitor (+0k6 code) diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 749cc8bb2..1b1325156 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -179,6 +179,7 @@ enum UserSelectablePins { GPIO_SHIFT595_SRCLK, GPIO_SHIFT595_RCLK, GPIO_SHIFT595_OE, GPIO_SHIFT595_SER, // 74x595 Shift register GPIO_SOLAXX1_RTS, // Solax Inverter Serial interface GPIO_OPTION_E, // Emulated module + GPIO_SDM230_TX, GPIO_SDM230_RX, // SDM230 Serial interface GPIO_SENSOR_END }; enum ProgramSelectablePins { @@ -393,11 +394,19 @@ const char kSensorNames[] PROGMEM = D_SENSOR_BL0939_RX "|" D_SENSOR_BL0942_RX "|" D_SENSOR_HM330X_SET "|" +<<<<<<< HEAD D_SENSOR_HEARTBEAT "|" D_SENSOR_HEARTBEAT "_i|" +<<<<<<< HEAD D_GPIO_SHIFT595_SRCLK "|" D_GPIO_SHIFT595_RCLK "|" D_GPIO_SHIFT595_OE "|" D_GPIO_SHIFT595_SER "|" D_SENSOR_SOLAXX1_RTS "|" D_SENSOR_OPTION " E|" ; +======= +======= + D_SENSOR_SDM230_TX "|" D_SENSOR_SDM230_RX +>>>>>>> changed: BUILDS.md + ; +>>>>>>> changed: BUILDS.md const char kSensorNamesFixed[] PROGMEM = D_SENSOR_USER; @@ -760,6 +769,10 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_SDM72_RX), // SDM72 Serial interface #endif AGPIO(GPIO_ZEROCROSS), +#ifdef USE_SDM230 + AGPIO(GPIO_SDM230_TX), // SDM230 Serial interface + AGPIO(GPIO_SDM230_RX), // SDM230 Serial interface +#endif #endif // USE_ENERGY_SENSOR /*-------------------------------------------------------------------------------------------*\ diff --git a/tasmota/tasmota_template_legacy.h b/tasmota/tasmota_template_legacy.h index 4583a9783..6a3115187 100644 --- a/tasmota/tasmota_template_legacy.h +++ b/tasmota/tasmota_template_legacy.h @@ -242,6 +242,8 @@ enum LegacyUserSelectablePins { GPI8_IEM3000_RX, // IEM3000 Serial interface GPI8_ZIGBEE_RST, // Zigbee reset GPI8_DYP_RX, + GPI8_SDM230_TX, // SDM230 Serial interface + GPI8_SDM230_RX, // SDM230 Serial interface GPI8_SENSOR_END }; // Programmer selectable GPIO functionality @@ -471,6 +473,8 @@ const uint16_t kGpioConvert[] PROGMEM = { AGPIO(GPIO_IEM3000_TX), // IEM3000 Serial interface AGPIO(GPIO_IEM3000_RX), // IEM3000 Serial interface AGPIO(GPIO_ZIGBEE_RST), // Zigbee reset + AGPIO(GPIO_SDM230_TX), // SDM230 Serial interface + AGPIO(GPIO_SDM230_RX), // SDM230 Serial interface AGPIO(GPIO_DYP_RX) }; diff --git a/tasmota/xdrv_03_energy.ino b/tasmota/xdrv_03_energy.ino index 161681e14..bcd6da9d7 100644 --- a/tasmota/xdrv_03_energy.ino +++ b/tasmota/xdrv_03_energy.ino @@ -1108,7 +1108,7 @@ void EnergyShow(bool json) { EnergyFormatSum(value2_chr, Energy.daily, Settings->flag2.energy_resolution, json)); /* - #if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) + #if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) || defined(SDM230_IMPORT) if (!isnan(Energy.import_active[0])) { ResponseAppend_P(PSTR(",\"" D_JSON_IMPORT_ACTIVE "\":%s"), EnergyFormat(value_chr, Energy.import_active, Settings->flag2.energy_resolution, json)); @@ -1117,7 +1117,7 @@ void EnergyShow(bool json) { EnergyFormatIndex(value_chr, energy_return, Settings->flag2.energy_resolution, json, 2)); } } -#endif // SDM630_IMPORT || SDM72_IMPEXP +#endif // SDM630_IMPORT || SDM72_IMPEXP || SDM230_IMPORT */ if (!isnan(Energy.export_active[0])) { diff --git a/tasmota/xnrg_21_sdm230.ino b/tasmota/xnrg_21_sdm230.ino new file mode 100644 index 000000000..fbb8af742 --- /dev/null +++ b/tasmota/xnrg_21_sdm230.ino @@ -0,0 +1,261 @@ +/* + xnrg_08_sdm230.ino - Eastron SDM230-Modbus energy meter support for Tasmota + + Copyright (C) 2021 Gennaro Tortone 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 + 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_SDM230 +/*********************************************************************************************\ + * Eastron SDM230 Modbus energy meter + * + * Based on: https://github.com/reaper7/SDM_Energy_Meter and https://github.com/nmakel/sdm_modbus +\*********************************************************************************************/ + +#define XNRG_21 21 + +// can be user defined in my_user_config.h +#ifndef SDM230_SPEED + #define SDM230_SPEED 2400 // default SDM230 Modbus address +#endif +// can be user defined in my_user_config.h +#ifndef SDM230_ADDR + #define SDM230_ADDR 1 // default SDM120 Modbus address +#endif + +#include +TasmotaModbus *Sdm230Modbus; + +const uint16_t sdm230_start_addresses[] { + 0x0000, // SDM230_VOLTAGE [V] + 0x0006, // SDM230_CURRENT [A] + 0x000C, // SDM230_POWER (Active) [W] + 0x0012, // SDM230_POWER (Apparent) G [VA] + 0x0018, // SDM230_POWER (Reactive) [VAr] + 0x001E, // SDM230_POWER_FACTOR + 0x0046, // SDM230_FREQUENCY [Hz] + 0X004A, // SDM230_EXPORT_ACTIVE [kWh] + 0X0180, // SDM230_RESETTABLE_TOTAL_ENERGY_ACTIVE [kWh] + 0X0056, // SDM230_MAXIMUM_TOTAL_DEMAND_POWER_ACTIVE [W] + 0x0024, // SDM230_PHASE ANGLE [Degree] +#ifdef SDM230_IMPORT + 0X0048, // SDM230_IMPORT_ACTIVE [kWh] +#endif // SDM230_IMPORT + 0X0156, // SDM230_TOTAL_ENERGY_ACTIVE [kWh] + +// 0X0158, // SDM230_TOTAL_ENERGY_REACTIVE [kVArh] +// 0X0182, // SDM230_RESETTABLE_TOTAL_ENERGY_REACTIVE [kVArh] +// 0X004C, // SDM230_IMPORT_REACTIVE [kVArh] +// 0X004E, // SDM230_EXPORT_REACTIVE [kVArh] +// 0X0054, // SDM230_TOTAL_DEMAND_POWER_ACTIVE [W] +// 0X0058, // SDM230_IMPORT_DEMAND_POWER_ACTIVE [W] +// 0X005A, // SDM230_MAXIMUM_IMPORT_DEMAND_POWER_ACTIVE [W] +// 0X005C, // SDM230_EXPORT_DEMAND_POWER_ACTIVE [W] +// 0X005E, // SDM230_MAXIMUM_EXPORT_DEMAND_POWER_ACTIVE [W] +// 0X0102, // SDM230_TOTAL_DEMAND_CURRENT [A] +// 0X0108, // SDM230_MAXIMUM_TOTAL_DEMAND_CURRENT [A] +}; + +struct SDM230 { + float resettable_total_energy = 0; + float maximum_total_demand_power = 0; + float phase_angle = 0; + uint8_t read_state = 0; + uint8_t send_retry = 0; +} Sdm230; + +/*********************************************************************************************/ + +void SDM230Every250ms(void) +{ + bool data_ready = Sdm230Modbus->ReceiveReady(); + + if (data_ready) { + uint8_t buffer[14]; // At least 5 + (2 * 2) = 9 + + uint32_t error = Sdm230Modbus->ReceiveBuffer(buffer, 2); + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Sdm230Modbus->ReceiveCount()); + + if (error) { + AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: SDM230 error %d"), error); + } else { + Energy.data_valid[0] = 0; + + // 0 1 2 3 4 5 6 7 8 + // SA FC BC Fh Fl Sh Sl Cl Ch + // 01 04 04 43 66 33 34 1B 38 = 230.2 Volt + 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(Sdm230.read_state) { + case 0: + Energy.voltage[0] = value; // 230.2 V + break; + + case 1: + Energy.current[0] = value; // 1.260 A + break; + + case 2: + Energy.active_power[0] = value; // -196.3 W + break; + + case 3: + Energy.apparent_power[0] = value; // 223.4 VA + break; + + case 4: + Energy.reactive_power[0] = value; // 92.2 + break; + + case 5: + Energy.power_factor[0] = value; // -0.91 + break; + + case 6: + Energy.frequency[0] = value; // 50.0 Hz + break; + + case 7: + Energy.export_active[0] = value; // 478.492 kWh + break; + + case 8: + Sdm230.resettable_total_energy = value; + break; + + case 9: + Sdm230.maximum_total_demand_power = value; + break; + + case 10: + Sdm230.phase_angle = value; // 0.00 Deg + break; + + case 11: + Energy.import_active[0] = value; // 6.216 kWh + break; + + case 12: + EnergyUpdateTotal(); + //Energy.export_active[0] = value; // 484.708 kWh = import_active + export_active + break; + } + + Sdm230.read_state++; + if (sizeof(sdm230_start_addresses)/2 == Sdm230.read_state) { + Sdm230.read_state = 0; + } + } + } // end data ready + + if (0 == Sdm230.send_retry || data_ready) { + Sdm230.send_retry = 5; + Sdm230Modbus->Send(SDM230_ADDR, 0x04, sdm230_start_addresses[Sdm230.read_state], 2); + } else { + Sdm230.send_retry--; + } +} + +void Sdm230SnsInit(void) +{ + Sdm230Modbus = new TasmotaModbus(Pin(GPIO_SDM230_RX), Pin(GPIO_SDM230_TX)); + uint8_t result = Sdm230Modbus->Begin(SDM230_SPEED); + if (result) { + if (2 == result) { ClaimSerial(); } + } else { + TasmotaGlobal.energy_driver = ENERGY_NONE; + } +} + +void Sdm230DrvInit(void) +{ + if (PinUsed(GPIO_SDM230_RX) && PinUsed(GPIO_SDM230_TX)) { + TasmotaGlobal.energy_driver = XNRG_21; + } +} + +void Sdm230Reset(void) +{ + Sdm230.resettable_total_energy = 0; + Sdm230.maximum_total_demand_power = 0; + Sdm230.phase_angle = 0; +} + +#ifdef USE_WEBSERVER +const char HTTP_ENERGY_SDM230[] PROGMEM = + "{s}" D_RESETTABLE_TOTAL_ACTIVE "{m}%s " D_UNIT_KILOWATTHOUR "{e}" + "{s}" D_MAX_POWER "{m}%s " D_UNIT_WATT "{e}" + "{s}" D_PHASE_ANGLE "{m}%s " D_UNIT_ANGLE "{e}"; +#endif // USE_WEBSERVER + +void Sdm230Show(bool json) +{ + char resettable_energy_chr[FLOATSZ]; + dtostrfd(Sdm230.resettable_total_energy, Settings->flag2.energy_resolution, resettable_energy_chr); + char maximum_demand_chr[FLOATSZ]; + dtostrfd(Sdm230.maximum_total_demand_power, Settings->flag2.wattage_resolution, maximum_demand_chr); + char phase_angle_chr[FLOATSZ]; + dtostrfd(Sdm230.phase_angle, 2, phase_angle_chr); + + if (json) { + ResponseAppend_P(PSTR(",\"" D_JSON_RESETTABLE_TOTAL_ACTIVE "\":%s,\"" D_JSON_POWERMAX "\":%s,\"" D_JSON_PHASE_ANGLE "\":%s"), + resettable_energy_chr, maximum_demand_chr, phase_angle_chr); +#ifdef USE_WEBSERVER + } else { + WSContentSend_PD(HTTP_ENERGY_SDM230, resettable_energy_chr, maximum_demand_chr, phase_angle_chr); +#endif // USE_WEBSERVER + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xnrg21(uint8_t function) +{ + bool result = false; + + switch (function) { + case FUNC_EVERY_250_MSECOND: + SDM230Every250ms(); + break; + case FUNC_JSON_APPEND: + Sdm230Show(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + Sdm230Show(0); + break; +#endif // USE_WEBSERVER + case FUNC_ENERGY_RESET: + Sdm230Reset(); + break; + case FUNC_INIT: + Sdm230SnsInit(); + break; + case FUNC_PRE_INIT: + Sdm230DrvInit(); + break; + } + return result; +} + +#endif // USE_SDM230 +#endif // USE_ENERGY_SENSOR