diff --git a/tasmota/include/tasmota_template.h b/tasmota/include/tasmota_template.h index 047e6766a..99358e81c 100644 --- a/tasmota/include/tasmota_template.h +++ b/tasmota/include/tasmota_template.h @@ -825,7 +825,7 @@ const uint16_t kGpioNiceList[] PROGMEM = { #endif #ifdef USE_CSE7766 AGPIO(GPIO_CSE7766_TX), // CSE7766 Serial interface (S31 and Pow R2) - AGPIO(GPIO_CSE7766_RX), // CSE7766 Serial interface (S31 and Pow R2) + AGPIO(GPIO_CSE7766_RX) + 2, // CSE7766 Serial interface (S31 and Pow R2) (1 = RX1 (8E1), 2 = RX2 (8N1)) #endif #ifdef USE_MCP39F501 AGPIO(GPIO_MCP39F5_TX), // MCP39F501 Serial interface (Shelly2) diff --git a/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino b/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino index fd2ccc11e..472f04cbc 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino @@ -225,11 +225,17 @@ void CseEverySecond(void) { void CseSnsInit(void) { // Software serial init needs to be done here as earlier (serial) interrupts may lead to Exceptions -// CseSerial = new TasmotaSerial(Pin(GPIO_CSE7766_RX), Pin(GPIO_CSE7766_TX), 1); - CseSerial = new TasmotaSerial(Pin(GPIO_CSE7766_RX), -1, 1); - if (CseSerial->begin(4800, SERIAL_8E1)) { + uint32_t pin_rx = Pin(GPIO_CSE7766_RX, GPIO_ANY); +// CseSerial = new TasmotaSerial(pin_rx, Pin(GPIO_CSE7766_TX), 1); + CseSerial = new TasmotaSerial(pin_rx, -1, 1); + + // 0 (1 = RX1 (8E1)), 1 (2 = RX2 (8N1)) + uint32_t option = GetPin(pin_rx) - AGPIO(GPIO_CSE7766_RX); + uint32_t config = (1 == option) ? SERIAL_8N1 : SERIAL_8E1; + if (CseSerial->begin(4800, config)) { if (CseSerial->hardwareSerial()) { - SetSerial(4800, TS_SERIAL_8E1); + config = (1 == option) ? TS_SERIAL_8N1 : TS_SERIAL_8E1; + SetSerial(4800, config); ClaimSerial(); } if (0 == Settings->param[P_CSE7766_INVALID_POWER]) { @@ -243,8 +249,8 @@ void CseSnsInit(void) { } void CseDrvInit(void) { -// if (PinUsed(GPIO_CSE7766_RX) && PinUsed(GPIO_CSE7766_TX)) { - if (PinUsed(GPIO_CSE7766_RX)) { +// if (PinUsed(GPIO_CSE7766_RX, GPIO_ANY) && PinUsed(GPIO_CSE7766_TX)) { + if (PinUsed(GPIO_CSE7766_RX, GPIO_ANY)) { Cse.rx_buffer = (uint8_t*)(malloc(CSE_BUFFER_SIZE)); if (Cse.rx_buffer != nullptr) { TasmotaGlobal.energy_driver = XNRG_02; diff --git a/tasmota/tasmota_xnrg_energy/xnrg_17_ornowe517.ino b/tasmota/tasmota_xnrg_energy/xnrg_17_ornowe517.ino index 3d1edf4e5..cbdb90d0f 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_17_ornowe517.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_17_ornowe517.ino @@ -189,7 +189,7 @@ void We517SnsInit(void) { if (result) { if (2 == result) { // AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED); -// Serial.begin(WE517_SPEED, SERIAL_8E1); + Serial.begin(WE517_SPEED, SERIAL_8E1); ClaimSerial(); } Energy.phase_count = 3;