From 90a9ebc3e1cf9b31761e1272053a7ebf37f376ba Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:52:44 +0200 Subject: [PATCH] Fix Shelly Pro ethernet stability --- tasmota/tasmota.ino | 1 + .../xdrv_88_esp32_shelly_pro.ino | 15 +++++++++++++++ tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino | 8 ++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index d33d122f6..707f95771 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -559,6 +559,7 @@ void setup(void) { bitWrite(Settings->rule_enabled, i, 0); // Disable rules causing boot loop } } + Settings->flag4.network_wifi = 1; // Enable wifi if disabled } if (RtcReboot.fast_reboot_count > Settings->param[P_BOOT_LOOP_OFFSET] +2) { // Restarted 4 times Settings->rule_enabled = 0; // Disable all rules diff --git a/tasmota/tasmota_xdrv_driver/xdrv_88_esp32_shelly_pro.ino b/tasmota/tasmota_xdrv_driver/xdrv_88_esp32_shelly_pro.ino index 486d79037..60f0f0a88 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_88_esp32_shelly_pro.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_88_esp32_shelly_pro.ino @@ -85,6 +85,18 @@ void ShellyProPreInit(void) { } } +void ShellyProInit(void) { + int pin_lan_reset = 5; // GPIO5 = LAN8720 nRST +// delay(30); // (t-purstd) This pin must be brought low for a minimum of 25 mS after power on + digitalWrite(pin_lan_reset, 0); + pinMode(pin_lan_reset, OUTPUT); + delay(1); // (t-rstia) This pin must be brought low for a minimum of 100 uS + digitalWrite(pin_lan_reset, 1); + + AddLog(LOG_LEVEL_INFO, PSTR("HDW: Shelly Pro %d%s initialized"), + TasmotaGlobal.devices_present, (PinUsed(GPIO_ADE7953_CS))?"PM":""); +} + void ShellyProPower(void) { SPro.power = XdrvMailbox.index &3; ShellyProUpdate(); @@ -147,6 +159,9 @@ bool Xdrv88(uint8_t function) { case FUNC_LED_LINK: ShellyProLedLink(); break; + case FUNC_INIT: + ShellyProInit(); + break; } } return result; diff --git a/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino b/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino index fc8e3411e..49686aca8 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_07_ade7953.ino @@ -370,8 +370,8 @@ void Ade7953Init(void) { Ade7953Write(0x0FE, 0x00AD); // Unlock register 0x120 Ade7953Write(0x120, 0x0030); // Configure optimum setting #ifdef USE_ESP32_SPI - int32_t value = Ade7953Read(0x702); // Silicon version - AddLog(LOG_LEVEL_DEBUG, PSTR("ADE: Chip%d version %d"), chip +1, value); +// int32_t value = Ade7953Read(0x702); // Silicon version +// AddLog(LOG_LEVEL_DEBUG, PSTR("ADE: Chip%d version %d"), chip +1, value); #endif // USE_ESP32_SPI } @@ -645,8 +645,8 @@ void Ade7953DrvInit(void) { } } else { #endif // USE_ESP32_SPI - if (!I2cSetDevice(ADE7953_ADDR)) { - return; + if (!I2cSetDevice(ADE7953_ADDR)) { + return; } I2cSetActiveFound(ADE7953_ADDR, "ADE7953"); #ifdef USE_ESP32_SPI