diff --git a/CHANGELOG.md b/CHANGELOG.md index c68129c06..158ea7f58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - Berry `math.min()` and `math.max()` (#21705) - Berry `FUNC_ANY_KEY` event calling `any_key()` (#21708) - Berry `FUNC_BUTTON_MULTI_PRESSED` event and make `FUNC_BUTTON_PRESSED` called only on state changes and once per second (#21711) +- Support for Sonoff POWCT Ring (#21131) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index b6380efb2..00b2eb0b4 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -123,6 +123,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Added - Support for QMP6988 temperature and pressure sensor - Support for Sonoff WTS01 temperature sensor using SerialBridge in ``SSerialMode 3`` +- Support for Sonoff POWCT Ring [#21131](https://github.com/arendst/Tasmota/issues/21131) - Extend command ``SetOption147 1`` to disable publish of IRReceived MQTT messages [#21574](https://github.com/arendst/Tasmota/issues/21574) - ESP32 support for power and energy limit checks, like ``MaxEnergy2`` per phase [#21695](https://github.com/arendst/Tasmota/issues/21695) - Berry solidification of `bytes` instances [#21558](https://github.com/arendst/Tasmota/issues/21558) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino b/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino index c1d544349..cce1f7c82 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino @@ -17,6 +17,7 @@ * {"NAME":"Sonoff THR316D GPIO26","GPIO":[32,0,0,0,225,9280,0,0,0,321,0,576,320,9184,9216,0,0,224,0,9248,0,1,1,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} * {"NAME":"Sonoff THR320D","GPIO":[32,0,0,0,226,9280,0,0,0,321,0,576,320,9184,9216,9312,0,0,9313,9248,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} * {"NAME":"Sonoff THR320D GPIO26","GPIO":[32,0,0,0,226,9280,0,0,0,321,0,576,320,9184,9216,9312,0,0,9313,9248,0,1,1,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} + * {"NAME":"Sonoff POWCT","GPIO":[32,0,0,0,0,9280,0,0,0,320,0,576,0,9184,9216,0,0,224,0,9248,0,7329,7296,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} * * DspSpeed 2..127 = Display rotation speed in seconds if more than one value is requested * DspLine<1|2> ,,,,... = Display specific JSON value and rotate between them @@ -51,12 +52,14 @@ #define TM1621_BIAS 0x29 // 0b00101001 = LCD 1/3 bias 4 commons option #define TM1621_IRQ_DIS 0x80 // 0b100x0xxx -enum Tm1621Device { TM1621_USER, TM1621_POWR316D, TM1621_THR316D }; +enum Tm1621Device { TM1621_USER, TM1621_POWR316D, TM1621_THR316D, TM1621_POWCT }; +const char tm1621_device PROGMEM[] = "User|PowR3|THR3|PowCT"; + enum Tm1621Units { TM1621_NONE, TM1621_TEMPERATURE, TM1621_HUMIDITY, TM1621_VOLTAGE_CURRENT, TM1621_ENERGY_POWER }; const uint8_t tm1621_commands[] = { TM1621_SYS_EN, TM1621_LCD_ON, TM1621_BIAS, TM1621_TIMER_DIS, TM1621_WDT_DIS, TM1621_TONE_OFF, TM1621_IRQ_DIS }; -const char tm1621_kchar[] PROGMEM = { " |0|1|2|3|4|5|6|7|8|9|-|E" }; +const char tm1621_kchar[] PROGMEM = " |0|1|2|3|4|5|6|7|8|9|-|E"; // b0 --- // b1 / / b4 // --- b5 @@ -307,7 +310,18 @@ void TM1621SendRows(void) { void TM1621PreInit(void) { if (!PinUsed(GPIO_TM1621_CS) || !PinUsed(GPIO_TM1621_WR) || !PinUsed(GPIO_TM1621_RD) || !PinUsed(GPIO_TM1621_DAT)) { return; } - Tm1621.device = (14 == Pin(GPIO_TM1621_DAT)) ? TM1621_POWR316D : (5 == Pin(GPIO_TM1621_DAT)) ? TM1621_THR316D : TM1621_USER; + Tm1621.device = TM1621_USER; + uint32_t pin_tm1621_dat = Pin(GPIO_TM1621_DAT); + if (5 == Pin(GPIO_TM1621_DAT)) { + if (25 == Pin(GPIO_CSE7761_RX, 1)) { + Tm1621.device = TM1621_POWCT; + } else { + Tm1621.device = TM1621_THR316D; + } + } + else if (14 == Pin(GPIO_TM1621_DAT)) { + Tm1621.device = TM1621_POWR316D; + } Tm1621.present = true; Tm1621.pin_da = Pin(GPIO_TM1621_DAT); Tm1621.pin_cs = Pin(GPIO_TM1621_CS); @@ -326,7 +340,9 @@ void TM1621PreInit(void) { Tm1621.state = 200; - AddLog(LOG_LEVEL_INFO, PSTR("DSP: TM1621")); + char stemp[8]; + AddLog(LOG_LEVEL_INFO, PSTR("DSP: TM1621 for %s"), + GetTextIndexed(stemp, sizeof(stemp), Tm1621.device, tm1621_device)); } void TM1621Init(void) { @@ -452,7 +468,8 @@ void TM1621Show(void) { } #ifdef USE_ENERGY_SENSOR - if (TM1621_POWR316D == Tm1621.device) { + if ((TM1621_POWR316D == Tm1621.device) || + (TM1621_POWCT == Tm1621.device)) { if (0 == Tm1621.display_rotate) { ext_snprintf_P(Tm1621.row[0], sizeof(Tm1621.row[0]), PSTR("%1_f"), &Energy->voltage[0]); ext_snprintf_P(Tm1621.row[1], sizeof(Tm1621.row[1]), PSTR("%1_f"), &Energy->current[0]); diff --git a/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino b/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino index 1ae32783d..ac44de9a6 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino @@ -20,7 +20,7 @@ #ifdef USE_ENERGY_SENSOR #ifdef USE_CSE7761 /*********************************************************************************************\ - * CSE7761 - Energy (Sonoff Dual R3 Pow and Pox CT) + * CSE7761 - Energy (Sonoff Dual R3 and Pow CT) * * Without zero-cross detection * {"NAME":"Sonoff Dual R3","GPIO":[32,0,0,0,0,0,0,0,0,576,225,0,0,0,0,0,0,0,0,0,0,7296,7328,224,0,0,0,0,160,161,0,0,0,0,0,0],"FLAG":0,"BASE":1} @@ -28,6 +28,8 @@ * With zero-cross detection * {"NAME":"Sonoff Dual R3 (ZCD)","GPIO":[32,0,0,0,7552,0,0,0,0,576,225,0,0,0,0,0,0,0,0,0,0,7296,7328,224,0,0,0,0,160,161,0,0,0,0,0,0],"FLAG":0,"BASE":1} * + * {"NAME":"Sonoff POWCT","GPIO":[32,0,0,0,0,9280,0,0,0,320,0,576,0,9184,9216,0,0,224,0,9248,0,7329,7296,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} + * * Based on datasheet from ChipSea and analysing serial data * See https://github.com/arendst/Tasmota/discussions/10793 * https://goldenrelay.en.alibaba.com/product/62119012875-811845870/GOLDEN_GI_1A_5LH_SPST_5V_5A_10A_250VAC_NO_18_5_10_5_15_3mm_sealed_type_all_certificate_compliances_class_F_SPDT_Form_available.html