I have a simple rain sensor module connected to my esp32 (battery + solar powered).
If it senses raindrops the signal will go low. The ESP also has a temperature sensor connected.
I want to achieve the following process:
No Rain:
- 4s run, 30min sleep
- rain sensor voltage on (to detect rain)
- temperature sensor voltage on, while running
Rain detected (output rain sensor low):
- interrupt sleep
- turn rain sensor voltage off (to avoid corrosion)
- set rain sensor state to “on” for 30min (until the normal cycle activates the rain sensor again)
- go into deep sleep for 30min
My Problem is, that when the esp should go into deep sleep it wakes up after ~1-4s and immediately goes back to sleep.
esphome:
name: $devicename
platform: ESP32
board: lolin32
on_boot:
then:
- output.turn_on: dht_supply
- output.turn_on: rainsensor_supply
on_shutdown:
then:
- output.turn_off: dht_supply
#WIFI
wifi:
ssid: !secret wifiname
password: !secret wifipw
fast_connect: true
manual_ip:
static_ip: !secret node_01_ip
gateway: !secret gatewayip
subnet: !secret subnet
dns1: !secret dnsip
dns2: !secret dnsip
power_save_mode: high
output_power: 10
# Enable logging
logger:
level: ERROR
#DeepSleep
deep_sleep:
run_duration: 4s
sleep_duration: 30min
id: deep_sleep_1
wakeup_pin: 27
wakeup_pin_mode: INVERT_WAKEUP
#MQTT
mqtt:
broker: !secret mqttbrokerip
username: !secret mqttuser
password: !secret mqttpass
topic_prefix: $devicename
discovery: False
discovery_retain: False
#3.3V Supply Switch
output:
#DHT22
- platform: gpio
pin: 26
id: dht_supply
#RAINSENSOR
- platform: gpio
pin: 23
id: rainsensor_supply
sensor:
#DHT22
- platform: dht
pin: 25
model: AM2302
update_interval: 2s
temperature:
name: "${devicename}_am2302_temperature"
binary_sensor:
#RAINSENSOR
- platform: gpio
id: regensensor
pin:
number: 27
inverted: true
mode: INPUT_PULLUP
name: "${devicename}_rainsensor"
filters:
- delayed_on: 30min
on_release:
then:
- output.turn_off: rainsensor_supply
- deep_sleep.enter: deep_sleep_1