Waking from deep sleep with button not working

Help!

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:

esphome:
  name: esp32-mailbox
  friendly_name: esp32-mailbox

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: xx

ota:
  password: xx

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


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

captive_portal:


deep_sleep:
  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