Is it possible to wake up my ESP32 with the same pin as a sensor?
I have a Rain Guage I’ve build, which uses Pin 27 with a hall effect sensor to detect a bucket tip for rain.
What I’d like to do is put the ESP32 to deep sleep until the bucket tip is detected, then stay wake for a minute, sending any successive tips, resetting that timer. Once it stops raining, the bucket stops tipping and a minute later, deep sleep resumes.
Here’s my current YAML:
substitutions:
wake_time: '60s'
esphome:
name: esp32-rain-gauge
friendly_name: ESP32 Rain Gauge
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxx"
ota:
password: "xxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Rain-Gauge"
password: "xxxxxxxxx"
captive_portal:
# Reed switch between GPIO and GND
sensor:
- platform: pulse_counter
pin:
number: GPIO27
name: rain_sensor
unit_of_measurement: mm
filters:
- multiply: 0.02
deep_sleep:
id: deep_sleep_component
sleep_duration: 30s
run_duration: 30s
esp32_ext1_wakeup:
mode: ALL_LOW
pins:
- 27
```