Terrible title, sorry for that. I keep getting frustratingly odd results.
Trying to add a new ESP32 module to my stable today. A TTGO T-Higrow with a set of sensors for air and soil measurements. It has a wake-up button connected to GPIO35.
I’ll rant about two issues – if anyone has ideas for what is happening here and how to fix it, I’m all ears.
Loosely based some of this on this post: 🔋 ESPHome: Batteries, Deep Sleep, and Over-the-Air Updates – Tatham Oddie
Issue 1, fetching data from HA. I can’t seem to fetch any sensor or state data from Home Assistant. I want a native way to block deep sleep when necessary. Was trying to use a helper entity, but even a regular sensor or input entity doesn’t seem to work for me. Tried the simple way as in the example above. Tried to force some kind of fetch of state with lambda, and even calls to id(xxx).setup(). Can’t get anything, from any type of HA entity, this way. I have another ESP8266 running a display, which fetches data from variables it itself updates, and that works fine. I haven’t updated that in a while though, since I’m now worried maybe it’ll break.
Issue 2, deep sleep. I want to dynamically call deep sleep via deep_sleep.enter using a configured deep_sleep component, to allow for some logic for when to sleep (relevant once issue 1 above is resolved). However, only some of the configuration in this deep_sleep component seems to be applied, and somewhat weirdly. First, “sleep_duration” in the deep_sleep component is not used when called this way, so I need to specify a duration in the “deep_sleep.enter” call. Second, I try to add a wakeup via the button connected to GPIO35. Not sure how this is wired on the board. Reading the variable gives a default-high state, so seems to be using a pull-up. When I configure “wakeup_pin: GPIO35” for the deep_sleep component, it always interrupts the deep sleep immediately. Even with “wakeup_pin_mode” at (what’s supposedly the default) “IGNORE”, it wakes up immediately. Configuring the pin as “inverted: true” doesn’t do anything for the deep_sleep mode.
esphome:
name: esp32module
on_boot:
then:
- script.execute: consider_deep_sleep
binary_sensor:
- platform: gpio
id: gpio_wakeup_pin
pin:
number: GPIO35
mode:
input: true
##mode: INPUT_PULLUP
## GPIO35 does not support setting pullup or pulldown mode in software
## but, seems to already be pulled up on this board so may need to set inverted to true for a default-low state
inverted: true
name: "Wake Button"
internal: true
deep_sleep:
id: deep_sleep_control
sleep_duration: 15s
wakeup_pin: GPIO35
script:
- id: consider_deep_sleep
mode: queued
then:
- delay: 10s
- logger.log: 'Entering sleep'
- deep_sleep.enter:
id: deep_sleep_control
sleep_duration: 15s
- script.execute: consider_deep_sleep
End rant. Suggestions welcome.
Running HA 2022.2.5, and ESPHome 2022.2.6.