Deep sleep wakeup_pin doesn't work on ESP32

Hi,

I can’t get the wake up pin to work.

Pin 13 is connected to 3.3v.

The connected pin 13 should block entering deep sleep, but it doesn’t. It enters deep sleep when the pin is connected and does the same when it is not connected.I want the ESP to wake up, when I connect pin 13 to 3.3v and I want it to stay active, when this pin is still connected.

When I check the pin with a binary sensor, it is ‘on’ when the pin is connected and ‘off’ when it’s not.

My ESPHome config:

esphome:
  name: kratos
  friendly_name: Kratos
  # Output für Stromversorgung des Lesekopfes aktivieren
  on_boot:
    - priority: 90
      then:
        - output.turn_on: sensor_energy



esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:


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

captive_portal:
    
web_server:
  port: 80

external_components:
    # IEC62056 component
    - source: github://aquaticus/esphome-iec62056

# Output für Stromversorgung des Lesekopfes auf Pin 12
output:
  - platform: gpio
    id: sensor_energy
    pin: 12

uart:
  id: uart_bus
  rx_pin: 16
  tx_pin: 17
  baud_rate: 9600
  data_bits: 7
  parity: EVEN
  stop_bits: 1
  debug:
    direction: BOTH

    
iec62056:
  #update_interval: 15s
  battery_meter: False
    
# Zählerstand auslesen
sensor:
  - platform: iec62056
    obis: 1.8.0
    name: Zählerstand
    unit_of_measurement: kWh
    accuracy_decimals: 0
    device_class: energy
    state_class: total_increasing

# Deep Sleep
deep_sleep: 
  id: sleeper
  run_duration: 3min
  sleep_duration: 3min
  wakeup_pin:
    number: 13
    mode:
      input: True
      pulldown: True
  wakeup_pin_mode: KEEP_AWAKE

Can anyone help?

Thanks!

Where does the 3.3V come from? External to the esp?

Maybe this could help?

https://www.reddit.com/r/homeassistant/comments/115v68y/esphome_and_detecting_33v_signal/

From the ESP Pin itself. An the ESP is currently driven through 5v USB. It behaves the same when powering with battery over the 3.3v pin.

Got it! If the Deep Sleep woke up by GPIO for one time, the KEEP_AWAKE option works. Don’t know if this is intended.
I’ve built a workaround to enable the function from beginning:


binary_sensor:
  - platform: gpio
    id: deep_sleep_pin
    name: "Deep Sleep"
    pin:
      number: 13
      #inverted: true
      allow_other_uses: true
      mode:
        input: true
        pulldown: true
    on_press:
      then: 
        - logger.log: "Jumper an. Kein Deep Sleep"
        - deep_sleep.prevent: sleeper
    on_release:
      then:
        - logger.log: "Jumper aus. Deep Slepp aktiviert"
        - deep_sleep.allow: sleeper

# Deep Sleep
deep_sleep: 
  id: sleeper
  run_duration: 2min
  sleep_duration: 2min
  wakeup_pin: 
    number: 13
    #inverted: True
    allow_other_uses: true
    mode:
      input: True
      pulldown: True
  wakeup_pin_mode: KEEP_AWAKE

Also it works, if you run “deep_sleep.enter” action instead of “sleep_duration”.

Thanks for publishing your code.
It has helped me a lot in solving another problem.