ESP32 - I cant wake up by touch sensor

Hi all

I tried to solution on my problem almost everywhere, but no success :frowning:

I have ESP32 connected to the home assistant and is powered by powerbank. I have deep sleep mode programmed and is almost working correctly :slight_smile:
Wake up by time is working perfectly, but I am not able wake up by configured touch sensor. Touch sensor is working correctly because if ESP is alive, then my sensor is working. Can me help somebody. I am totally frustrated, that I am lost maybe one week with finding some solution, but nothing works. I tried connect power supply with USB port and by VIN pins, both connection doesn’t help.

My code is:

sphome:
  name: esp-pool
  friendly_name: ESP pool

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "fhryr/eg="

ota:
  - platform: esphome
    password: "42de63436"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Pool"
    password: "789"
  
web_server:
  port: 80
  version: 2

deep_sleep:
  run_duration:
    default: 
      seconds: 30
    touch_wakeup_reason: 
      seconds: 60
  sleep_duration: 2min
  touch_wakeup: true
  id: deep_sleep_1
  
captive_portal:

one_wire:
  - platform: gpio
    pin: GPIO17

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: false
  id: bus_a
  frequency: 800kHz

esp32_touch:
    setup_mode: false

binary_sensor:
  - platform: esp32_touch
    name: "Touch Pad"
    pin: GPIO4
    id: sensor_touch
    threshold: 1000
    wakeup_threshold: 1000
    on_press: 
      then:
        - binary_sensor.template.publish:
            id: backlight
            state: ON
        - switch.turn_on: display_relay

        - binary_sensor.template.publish:
            id: backlight
            state: OFF
     on_release: 
      then:
        - switch.turn_off: display_relay

  - platform: template
    id: backlight
    filters:
      - delayed_off: 10s
    on_press:
      then:
        - lambda: |-
            id(mydisplay).backlight();
    on_release:
      then:
        - lambda: |-
            id(mydisplay).no_backlight();

  - platform: status
    name: "ESP pool wifi"
    on_state:
      then:
        - if:
            condition:
              wifi.connected:
            then:
              - output.turn_on: blue_led
            else:
              - output.turn_off: blue_led

      
sensor:
  - platform: dallas_temp
    address: 0xbf41d6d446357528
    name: Teplota bazena
    id: Temp_Pool
    unit_of_measurement: Β°C
    icon: "mdi:thermometer-plus"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 1
    update_interval: 10s

  - platform: template
    name: "Wakeup Cause"
    accuracy_decimals: 0
    lambda: return esp_sleep_get_wakeup_cause();

switch:
  - platform: gpio
    name: "Osvetlenie"
    id: display_relay
    pin:
      number: 19
      mode: OUTPUT

output:
  - platform: gpio
    pin: GPIO2
    id: blue_led