Waking from deep sleep with button not working


I’m building a sensor to report when postman has been at the mailbox, however, I’m unable to wake up my ESP32 from deep sleep using a tilt sensor (or button). My passive tilt sensor (just the one with a bearing inside) is soldered between GPIO33 and ground. Also tried it with different pins, both with/without 10kohm pulldown resistor.

Could someone kindly tell what I’m doing wrong, I’m losing hope. My configutation is the following:

  name: esp32-mailbox
  friendly_name: esp32-mailbox

  board: esp32dev
    type: arduino

# Enable logging

# Enable Home Assistant API
    key: xx

  password: xx

#  fast_connect: true
  ssid: !secret wifi_ssid
  password: !secret wifi_password
    static_ip: xx
    gateway: xx
    subnet: xx

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: xx
    password: xx


  run_duration: 20s
  sleep_duration: 20s  # will increase this to days/weeks as it seems some value is to be given
  wakeup_pin: GPIO33
  # wakeup_pin_mode: INVERT_WAKEUP  # tried with and without this, no difference 
  # inverted: True   # tried with and without this, no difference

Does your tilt sensor work when just set-up as a regular gpio binary sensor with deep sleep mode disabled?

That will help diagnose what layer your issue is in.

Yes. I also tried replacing it with a regular microswitch but the result is the same - it does not work.

A simple way of bringing an ESP32 out of sleep is to bring the EN(RST) pin down to ground momentarily. Connect your switch across those pins and try. No need for any code. It will require the switch goes back to its open position.

1 Like

This works and solved my problem. Thank you very much!

Glad it worked. The picture describes what happens. I checked and there is a 10K resistor pulling EN high just enough provided switch isn’t allowing EN to be pulled harder to ground(it measures as 11k on my ESP32 and 470 resistor between EN and the physical small reboot button). The 10K should be enough to allow only a very tiny current to run from 3.3V rail to Ground so not a short circuit. As far as I am aware it just reproducing the reboot button on the ESP32 module so would suggest you add a 470ohm resistor between your external switch and the EN pin just for extra safety.

1 Like