Reset Reason "RTC Watch Dog Reset Digital Core And RTC Module" on esp32s nodemcu (2)

Hi, I’ve gotten a power monitor setup using CircuitSetup Expandable 6 Channel ESP32 Energy Meter and esp32s nodemcu (aliexpress link). About every 12hrs I see that the ESP32 has reset and the reset reason is “RTC Watch Dog Reset Digital Core And RTC Module”. It is also happening at around 4am and 4pm every day. Below is my configuration and I have searched online on various sites for any similar cases but couldn’t find any. The version of ESPHome I’m using is 2023.2.4.

esp32s-energy-meter-1.yaml
esphome:
  name: esp32s-energy-meter-1
  platform: ESP32
  board: nodemcu-32s
  on_boot:
    priority: 300 #After sensors are up but before WIFI is connected
    then:
      - logger.log:
          format: "on_boot started"
          level: INFO
          tag: energy-meter-1
      # - delay: 1s
      # - if:
      #     condition:
      #       - time.has_time:
      #     then:
      #       - logger.log:
      #           format: "on_boot Time has been set and is valid!"
      #           level: INFO
      #           tag: energy-meter-1
      #       - globals.set:
      #         id: boot_time
      #         value: !lambda |-
      #           return 
      #       - lambda: |-
      #           id(bootTime).publish_state(id(sntpTime).now().strftime("on_boot %Y-%m-%d %I:%M:%S %p %z"));
      # - globals.set:
      #     id: previous_total_mains_forward_active_power
      #     value: '0.0f'
      # - globals.set:
      #     id: current_total_mains_forward_active_power
      #     value: '355533000.0f'
      # - globals.set:
      #     id: previous_total_mains_forward_active_power
      #     value: !lambda 'return id(current_total_mains_forward_active_power);'
      # - lambda: |-
      #     ESP_LOGI("energy-meter-1", "on_boot previous_total_mains_forward_active_power %s", id(previous_total_mains_forward_active_power));
      #     ESP_LOGI("energy-meter-1", "on_boot current_total_mains_forward_active_power %s", id(current_total_mains_forward_active_power));
      - globals.set:
          id: boot_completed
          value: 'true'
      - logger.log:
          format: "on_boot finished"
          level: INFO
          tag: energy-meter-1

# Enable logging
logger:
  # baud_rate: 19200
  logs:
    sensor: INFO
    text_sensor: INFO

# Enable Home Assistant API
api:
  reboot_timeout: 0s
  services:
    - service: set_previous_total_mains_forward_active_power
      variables:
        value: float
      then:
        - globals.set:
            id: previous_total_mains_forward_active_power
            value: !lambda 'return value;'

ota:
  password: <ommitted>

wifi:
  ssid: <ommitted>
  password: <ommitted>
  # ssid: <ommitted>
  # password: <ommitted>
  fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: <ommitted>
    password: <ommitted>

captive_portal:

web_server:
  port: 80

debug:
  update_interval: 30s

time:
  - platform: sntp
    id: sntpTime
    timezone: <ommitted>
    # timezone: <ommitted>
    on_time_sync:
      then:
        - logger.log:
            format: "on_time_sync Synchronized system clock"
            level: INFO
            tag: energy-meter-1
        - lambda: |-
            if (!id(time_synced)) {
              id(bootTime).publish_state(id(sntpTime).now().strftime("on_time_sync %Y-%m-%d %I:%M:%S %p %z"));
              id(hardwareStatus).turn_on().perform();
            }
        - globals.set:
            id: time_synced
            value: 'true'

globals:
  - id: boot_completed
    type: bool
    restore_value: false
    initial_value: 'false'
  - id: time_synced
    type: bool
    restore_value: false
    initial_value: 'false'
  - id: total_mains_forward_active_energy_updated
    type: bool
    restore_value: false
    initial_value: 'false'
  - id: previous_total_mains_forward_active_power
    type: float
    restore_value: false
    initial_value: '0.0f'
  - id: current_total_mains_forward_active_power
    type: float
    restore_value: true
    initial_value: '1.0f'
  # - id: boot_time
  #   type: std::string
  #   restore_value: no
  #   initial_value: '"undefined yyyy-MM-dd HH:mm:ss"'

spi:
  clk_pin: 18
  miso_pin: 19
  mosi_pin: 23

#substitutions:
  # Change the disp_name to something you want  
    # disp_name: energy-meter-1
  # Current Transformers:
  #  20A/25mA SCT-006: 11143
  #  30A/1V SCT-013-030: 8650
  #  50A/1V SCT-013-050: 15420
  #  80A/26.6mA SCT-010: 41660
  #  100A/50ma SCT-013-000: 27518
  #  120A/40mA: SCT-016: 41787
  #  200A/100mA SCT-024: 27518
    #current_cal: '30853'
  # Jameco 9VAC Transformer: 
  #  For meter versions: 
  #  >= v1.3: 7305
    #voltage_cal: '11847'

light:
  - platform: status_led
    name: "Hardware Status"
    id: hardwareStatus
    pin: GPIO2
    restore_mode: ALWAYS_OFF

text_sensor:
  - platform: debug
    reset_reason:
      name: Reset Reason
  - platform: version
    name: ESPHome Version
  - platform: template
    name: Boot Time
    id: bootTime

sensor:
  - platform: debug
    free:
      name: Heap Free
  - platform: wifi_signal
    name: WiFi Signal
    update_interval: 60s
  - platform: template
    name: Total Mains Forward Active Power
    id: totalMainsForwardActivePower
    lambda:  |-
      ESP_LOGI("energy-meter-1", "totalMainsForwardActivePower running");
      if (!id(total_mains_forward_active_energy_updated)) {
        ESP_LOGI("energy-meter-1", "totalMainsForwardActivePower global variables not updated");
        ESP_LOGI("energy-meter-1", 
          "totalMainsForwardActivePower initial previous_total_mains_forward_active_power %f", 
          id(previous_total_mains_forward_active_power));
        ESP_LOGI("energy-meter-1", 
          "totalMainsForwardActivePower initial current_total_mains_forward_active_power %f", 
          id(current_total_mains_forward_active_power));
      
        ESP_LOGI("energy-meter-1", "totalMainsForwardActivePower updating");
        if (id(current_total_mains_forward_active_power) == id(current_total_mains_forward_active_power)) {
          id(previous_total_mains_forward_active_power) = id(current_total_mains_forward_active_power);
        } else {
          ESP_LOGW("energy-meter-1",
            "totalMainsForwardActivePower current_total_mains_forward_active_power is not set!");
          id(previous_total_mains_forward_active_power) = 0.0f;
        }
        
        id(total_mains_forward_active_energy_updated) = true;
      }
      ESP_LOGD("energy-meter-1", "l0ct4fWh state %f", id(l0ct4fWh).state);
      ESP_LOGD("energy-meter-1", "l1ct1fWh state %f", id(l1ct1fWh).state);
      ESP_LOGD("energy-meter-1", "l2ct1fWh state %f", id(l2ct1fWh).state);
      ESP_LOGD("energy-meter-1", "previous_total_mains_forward_active_power %f", id(previous_total_mains_forward_active_power));
      if (id(l0ct4fWh).state == id(l0ct4fWh).state && 
        id(l1ct1fWh).state == id(l1ct1fWh).state && 
        id(l2ct1fWh).state == id(l2ct1fWh).state) {
          id(current_total_mains_forward_active_power) = 
            id(l0ct4fWh).state + id(l1ct1fWh).state + 
            id(l2ct1fWh).state + id(previous_total_mains_forward_active_power);
          ESP_LOGI("energy-meter-1", "totalMainsForwardActivePower current_total_mains_forward_active_power %f", id(current_total_mains_forward_active_power));
          return id(current_total_mains_forward_active_power);
      }
      return -1.0f;
    accuracy_decimals: 2
    unit_of_measurement: Wh
    icon: "mdi:flash-circle"
    device_class: energy
    state_class: total
    update_interval: 5s
  - platform: atm90e32
    # layer 0 - UPS - CT1-3
    line_frequency: 50Hz
    cs_pin: 5
    current_phases: 3
    update_interval: 5s
    gain_pga: 1X
    frequency:
      name: UPS Main Freq
    phase_a:
      voltage:
        name: UPS Main Volts
        id: l0ic1Volts
        accuracy_decimals: 1
      current:
        name: UPS Main Amps (l0ct1)
        id: l0ct1Amps
      power:
        name: UPS Main Watts (l0ct1)
        id: l0ct1Watts
      reactive_power:
        name: UPS Main VARs
        id: l0ct1Var
      power_factor:
        name: UPS Main PF
        id: l0ct1Pf
      forward_active_energy:
        name: UPS Main Forward Wh
        id: l0ct1fWh
      reverse_active_energy:
        name: UPS Main Reverse Wh
        id: l0ct1rWh
      gain_voltage: 11157
      gain_ct: 27932
  - platform: atm90e32
    # layer 0 - Mains 3 - CT4-6
    line_frequency: 50Hz
    cs_pin: 4
    current_phases: 3
    update_interval: 5s
    gain_pga: 1X
    frequency:
      name: Mains 3 Freq
    phase_a:
      voltage:
        name: Mains 3 Volts
        id: l0ic2Volts
        accuracy_decimals: 1
      current:
        name: Mains 3 Amps (l0ct4)
        id: l0ct4Amps
      power:
        name: Mains 3 Watts (l0ct4)
        id: l0ct4Watts
      reactive_power:
        name:  Mains 3 VARs
        id: l0ct4Var
      power_factor:
        name:  Mains 3 PF
        id: l0ct4Pf
      forward_active_energy:
        name:  Mains 3 Forward Wh
        id: l0ct4fWh
      reverse_active_energy:
        name:  Mains 3 Reverse Wh
        id: l0ct4rWh
      gain_voltage: 14545
      gain_ct: 27562
    phase_b:
      current:
        name: <ommitted>
        id: l0ct5Amps
      power:
        name: <ommitted>
        id: l0ct5Watts
      gain_voltage: 14545
      gain_ct: 27562
    phase_c:
      current:
        name: <ommitted>
        id: l0ct6Amps
      power:
        name: <ommitted>
        id: l0ct6Watts
      gain_voltage: 14545
      gain_ct: 27562
  - platform: atm90e32
    # layer 1 - Mains 1 - CT1-3
    line_frequency: 50Hz
    cs_pin: 0
    current_phases: 3
    update_interval: 5s
    gain_pga: 1X
    frequency:
      name: Mains 1 Freq
    phase_a:
      voltage:
        name: Mains 1 Volts
        id: l1ic1Volts
        accuracy_decimals: 1
      current:
        name: Mains 1 Amps (l1ct1)
        id: l1ct1Amps
      power:
        name: Mains 1 Watts (l1ct1)
        id: l1ct1Watts
      reactive_power:
        name: Mains 1 VARs
        id: l1ct1Var
      power_factor:
        name: Mains 1 PF
        id: l1ct1Pf
      forward_active_energy:
        name: Mains 1 Forward Wh
        id: l1ct1fWh
      reverse_active_energy:
        name: Mains 1 Reverse Wh
        id: l1ct1rWh
      gain_voltage: 14508
      gain_ct: 28130
    phase_b:
      current:
        name: <ommitted>
        id: l1ct2Amps
      power:
        name: <ommitted>
        id: l1ct2Watts
      gain_voltage: 14508
      gain_ct: 27562
    phase_c:
      current:
        name: <ommitted>
        id: l1ct3Amps
      power:
        name: <ommitted>
        id: l1ct3Watts
      gain_voltage: 14508
      gain_ct: 26373
  - platform: atm90e32
    # layer 1 - Mains 1 - CT4-6
    line_frequency: 50Hz
    cs_pin: 16
    current_phases: 3
    update_interval: 5s
    gain_pga: 1X
    phase_a:
      current:
        name: <ommitted>
        id: l1ct4Amps
      power:
        name: <ommitted>
        id: l1ct4Watts
      gain_voltage: 14508
      gain_ct: 27562
    phase_b:
      current:
        name: <ommitted>
        id: l1ct5Amps
      power:
        name: <ommitted>
        id: l1ct5Watts
      gain_voltage: 14508
      gain_ct: 27740
    phase_c:
      current:
        name: <ommitted>
        id: l1ct6Amps
      power:
        name: <ommitted>
        id: l1ct6Watts
      gain_voltage: 14508
      gain_ct: 26373
  - platform: atm90e32
    # layer 2 - Mains 2 - CT1-3
    line_frequency: 50Hz
    cs_pin: 27
    current_phases: 3
    update_interval: 5s
    gain_pga: 1X
    frequency:
      name: Mains 2 Freq
    phase_a:
      voltage:
        name: Mains 2 Volts
        id: l2ic1Volts
        accuracy_decimals: 1
      current:
        name: Mains 2 Amps (l2ct1)
        id: l2ct1Amps
      power:
        name: Mains 2 Watts (l2ct1)
        id: l2ct1Watts
      reactive_power:
        name: Mains 2 VARs
        id: l2ct1Var
      power_factor:
        name: Mains 2 PF
        id: l2ct1Pf
      forward_active_energy:
        name: Mains 2 Forward Wh
        id: l2ct1fWh
      reverse_active_energy:
        name: Mains 2 Reverse Wh
        id: l2ct1rWh
      gain_voltage: 14582
      gain_ct: 27562
    phase_b:
      current:
        name: <ommitted>
        id: l2ct2Amps
      power:
        name: <ommitted>
        id: l2ct2Watts
      gain_voltage: 14582
      gain_ct: 27562
    phase_c:
      current:
        name: <ommitted>
        id: l2ct3Amps
      power:
        name: <ommitted>
        id: l2ct3Watts
      gain_voltage: 14582
      gain_ct: 27562

button:
  - platform: restart
    name: Restart
  - platform: safe_mode
    name: Safe Mode

Recently the esp32 has reset after 24hrs, ie at 4am today with the same reset reason.

As an update right now, it seems to be hanging bad enough for it not to be reachable from the network, I doubt the wifi is not reaching enough, so I guess I’m in one of those cases were I need to do more debugging cause of a more serious problem. Would appreciate if someone could recommend me a serial to sd card solution, that is because I want to save everything coming out of the serial to an sdcard and be able to view it later on after the issue randomly happened on the esp32. I think the openlog solutions from sparkfun are good options, but still looking around.

Did you find out the cause for constant watchdog resets?