ESP32 hangs on boot after every OTA

Good morning!

I have connected a touch sensor to an ESP32 according to these instructions and two additional servos.

Actually everything works fine, but after an OTA the device is stuck somewhere during boot: it can be reached via ping, but webfronted and API are not connected.

If I then disconnect and reconnect the power supply, it boots up normally again.

Here is the code:

substitutions:
  name: "hr_gastherme"
  friendly_name: "Heizungsraum Gastherme"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: XXX.XXX.XXX.XXX
    gateway: XXX.XXX.XXX.XXX
    subnet: XXX.XXX.XXX.XXX
  reboot_timeout: 5min
  ap:
    ap_timeout: 24h
    ssid: “${friendly_name} AP"
    password: !secret ap_password

web_server:
  port: 80

api:
  encryption:
    key: XXXXXXXXXXXXXXXXXXXXX
  reboot_timeout: 5min

ota:

mdns:
  disabled: false

logger:

esp32_touch:
# setup_mode: True
  iir_filter: 10ms

binary_sensor:
  - platform: esp32_touch
    name: "Heizungsraum Wasserleck"
    id: wasserleck
    pin: GPIO27
    threshold: 100

output:
  - platform: ledc
    id: heizungswasser_regler_pwm
    pin: GPIO16
    frequency: 50 Hz
  - platform: ledc
    id: brauchwasser_regler_pwm
    pin: GPIO17
    frequency: 50 Hz

servo:
  - id: heizungswasser_regler
    output: heizungswasser_regler_pwm
    transition_length: 6s
    restore: true
  - id: brauchwasser_regler
    output: brauchwasser_regler_pwm
    transition_length: 6s
    restore: true

select: 
  - platform: template
    name: 'Heizungswasser vorwärmen:'
    icon: "mdi:heating-coil"
    id: heizungswasser_wahl
    optimistic: true
    options:
      - "Aus"
      - "Stufe 1"
      - "Stufe 2"
      - "Stufe 3"
      - "Stufe 4"
      - "Stufe 5"
      - "Sparbetrieb"
      - "Maximum"
    set_action:
      then:
          - delay: 1s
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Aus";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: -100
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Stufe 1";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: -70
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Stufe 2";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: -40
          - if:  
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Stufe 3";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: -10
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Stufe 4";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: 25
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Stufe 5";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: 50
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Sparbetrieb";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: 75
          - if:
              condition:
                - lambda: |-
                    return (id(heizungswasser_wahl).state) == "Maximum";
              then:
                - number.set:
                    id: heizungswasser_temperatur
                    value: 100

  - platform: template
    name: 'Brauchwasser vorwärmen:'
    icon: "mdi:hand-water"
    id: brauchwasser_wahl
    optimistic: true
    options: 
      - "Aus"
      - "Stufe 1"
      - "Stufe 2"
      - "Stufe 3"
      - "Stufe 4"
      - "Stufe 5"
      - "Sparbetrieb"
      - "Stufe 6"
      - "Maximum"
    set_action:
      then:
          - delay: 1s
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Aus";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: -100
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Stufe 1";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: -75
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Stufe 2";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: -50
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Stufe 3";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: -25 
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Stufe 4";
              then:
                - delay: 1s
                - number.set:
                    id: brauchwasser_temperatur
                    value: 0 
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Stufe 5";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: 25
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Sparbetrieb";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: 50
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Stufe 7";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: 75
          - if:
              condition:
                - lambda: |-
                    return (id(brauchwasser_wahl).state) == "Maximum";
              then:
                - number.set:
                    id: brauchwasser_temperatur
                    value: 100
  
number:
  - platform: template
    name: Heizungswassertemperatur
    id: heizungswasser_temperatur
    internal: true
    min_value: -100
    initial_value: 0
    max_value: 100
    step: 1
    optimistic: true
    restore_value: true
    set_action:
      then:
        - servo.write:
            id: heizungswasser_regler
            level: !lambda 'return x / 100.0;'
  - platform: template
    name: Brauchwassertemperatur
    id: brauchwasser_temperatur
    internal: true
    min_value: -100
    initial_value: 0
    max_value: 100
    step: 1
    optimistic: true
    restore_value: true
    set_action:
      then:
        - servo.write:
            id: brauchwasser_regler
            level: !lambda 'return x / 100.0;'

Unfortunately I also get no log-output, so I can’t say exactly where it is stuck. However, if I do not connect the touch sensor, it runs without any problems.

As far as I can tell, however, I have done everything correctly in tom_i’s instructions, or can you find the error?

Any help would be highly appreciated!

I have exactly the same problem but on a D1 mini with a simple BME280 sensor on battery shield after an OTA.
No log output most of the time or boot log interrupted somewhere in the middle after OTA and upon each reset button press.
Works fine for the rest :thinking:

Thank you for your reply. Browsed the posts meanwhile and found several posts concerning this issue: but never a solution… :frowning: @tom_l : did you have similar problems or were your ESPs only equipped with the waterless-sensors?

I have never had this issue.