Hi there,
I have following problem:
My ESP32 ( FireBeetle 2 ESP32) doesn‘t go to sleep, respectively it goes to sleep and wakes up a few seconds later.
My code:
esphome:
name: $devicename
on_boot:
priority: -200
then:
- wait_until:
condition:
wifi.connected:
timeout: 5s
esp32:
board: esp32dev
framework:
type: arduino
deep_sleep:
run_duration: 60s
sleep_duration: 1h
id: deep_sleep_1
wakeup_pin:
id: defeat
number: 25
inverted: True
mode: INPUT_PULLUP
wakeup_pin_mode: KEEP_AWAKE
touch_wakeup: false
# Enable logging
logger:
#level: VERY_VERBOSE
# Enable Home Assistant API
api:
encryption:
key: !secret esphome_api_encryption_key
ota:
password: !secret esphome_ota
platform: esphome
wifi:
fast_connect: true
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${devicename}_FH"
password: !secret wifi_hotspot_password
manual_ip:
static_ip: $ip
gateway: 10.37.80.1
subnet: 255.255.255.0
dns1: 10.37.80.1
captive_portal:
esp32_touch:
setup_mode: false
switch:
- platform: restart
name: "Reboot ESP32"
icon: "mdi:restart"
binary_sensor:
- platform: status
name: "${upper_devicename} Status"
- platform: esp32_touch
pin: GPIO15
threshold: 2000
id: capacitive_level_hack
- platform: gpio
name: "${upper_devicename} Defeat"
entity_category: "diagnostic"
pin:
number: 16
mode: INPUT_PULLUP
inverted: false
on_press:
then:
- logger.log: "Prevent deep sleep"
- deep_sleep.prevent: deep_sleep_1
on_release:
then:
- logger.log: "Allow deep sleep"
- deep_sleep.allow: deep_sleep_1
sensor:
- platform: template
name: "${upper_devicename}"
- platform: adc
name: "${upper_devicename} Battery voltage"
pin: GPIO34
id: GPIO34
accuracy_decimals: 2
device_class: "power"
update_interval: 5s
attenuation: 12dB
filters:
- multiply: 2.0 # The voltage divider requires us to multiply by 2
- quantile:
window_size: 7
send_every: 4
send_first_at: 3
quantile: .9
entity_category: "diagnostic"
- platform: template
name: "${upper_devicename} Battery Percent"
icon: mdi:car-coolant-level
device_class: battery
update_interval: 15s
unit_of_measurement: "%"
accuracy_decimals: 0
lambda: |-
return (float) ((id(GPIO34).state));
filters:
- calibrate_polynomial:
degree: 2
datapoints:
# Map 0.0 (from sensor) to 0.0 (true value)
- 4.3 -> 100.0
- 4.2 -> 100.0
- 4.1 -> 94.0
- 4.0 -> 84.0
- 3.9 -> 74.0
- 3.8 -> 62.0
- 3.7 -> 53.0
- 3.6 -> 39.0
- 3.5 -> 22.0
- 3.4 -> 13.0
- 3.3 -> 3.0
- 3.2 -> 0.0
- 3.1 -> 0.0
- heartbeat: 20s
entity_category: "diagnostic"
- platform: template
name: "${upper_devicename} Wakeup Cause"
accuracy_decimals: 0
lambda: return esp_sleep_get_wakeup_cause();
entity_category: "diagnostic"
text_sensor:
# Reports the ESPHome Version with compile date
- platform: version
name: ${upper_devicename} ESPHome Version
button:
- platform: template
name: "OTA Mode"
id: otamode
#optimistic: True
#restore_value: True
entity_category: "config"
Here the logs:
[20:42:11][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[20:42:11][D][esp32.preferences:114]: Saving 1 preferences to flash...
[20:42:11][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[20:42:12][I][deep_sleep:060]: Beginning Deep Sleep
[20:42:12][I][deep_sleep:062]: Sleeping for 3600000000us
[20:42:12][D][esp32.preferences:114]: Saving 1 preferences to flash...
[20:42:12][D][esp32.preferences:143]: Saving 1 preferences to flash: 1 cached, 0 written, 0 failed
INFO Processing expected disconnect from ESPHome API for waterlevel-humidificator @ xx.xx.xx.xx
WARNING Disconnected from API
INFO Successfully connected to waterlevel-humidificator @ xx.xx.xx.xx in 0.291s
INFO Successful handshake with waterlevel-humidificator @ xx.xx.xx.xx in 0.160s
[20:42:21][D][sensor:094]: 'WaterLevel Humidificator Battery voltage': Sending state 4.26400 V with 2 decimals of accuracy
Where could be the problem?
It has worked for 2 years now. But since an update between spring and autumn.
Regards
Adrian