I got everything working the way I like so far: partial updates, sensors updating only when data arrives and stuff like that, but when I try to add deep sleep, the display seems to reset (flashing and erasing) every time it wakes up. I don’t want that, I want it to reset/full update only every so many updates, with deep sleep in between.
I’m not sure how deep sleep actually works. It is my understanding that it effectively shuts down and boots up every deep sleep cycle, so the on_shutdown and on_boot are called every time. That would also mean that all objects are recreated from scratch. It’s not some kind of PC hibernate where the RAM is written to disk and then reloaded, right?
That means setup() is called each wake up and judging from the code, that would call setup_pins_(), which will in turn call reset_(), explaining the observed behaviour. Or am I missing something?
Not setting the reset_pin (if that’s possible) might avoid this, but you would not be able to reset ever…
I also noticed a deep_sleep() function. Is that something that you need to call yourself (in on_shutdown), or is that somehow done automagically?
I also noticed the at_update_ property, which is initialized to 0 and works together with the full_update_every flag. You get a full update when at_update_ is 0, which is incremented each update and then modulo of full_update_every_. So if the objects are re-initialized every wake-up they will do a full update every time…
Is what I’m trying to achieve not possible, or am I missing something obvious?
The deep sleep component does indeed cause a full shutdown and boot each cycle.
epaper screens have 2 sleep states: normal sleep, and deep sleep. In normal sleep, the latest screen data is retained, and a reset is not needed, but more power is required (about 20µA). In real deep sleep, the data is lost and a full reset is needed, but less power is consumed (about 5µA).
The deep_sleep() function of the waveshare epaper is automatically called from the on_safe_shutdown hook in the waveshare component, which in turn is called from the App.run_safe_shutdown_hooks(), being called when the deep sleep component goes to sleep.
So my epaper display is always put into deep sleep when the ESP goes into deep sleep.
For use cases where the screen is very rarely updated, that might be the best option, but for my application (a thermostat) it would be nice if one could chose that.
Maybe I’ll have a stab at getting it to behave the way I want it, but that will require some experimentation, it seems!
No, that didn’t seem to work at the time I was implementing this with my ePaper (TTGO T5 2.13 inch with DKE display). I managed to get it to somewhat do what I like by changing the code a bit and saving the number of updates to flash.
If I find some time in the near future, I’ll revisit this and check if I maybe overlooked something.
The problem I have now is that the first update seems to take too long after wakeup, which is not ideal for a thermostat.
Me too, I’ve read so many deep sleep threads, but I still didn’t find a solution.
I think the deep sleep of the ESP32 works, following the logs, but my ePaper display is still drawing too much current. The standby current is 440 uA but should be max. 225 uA. It was measured directly after display refresh is done and ESP32 went into deep sleep following its logs. Furthermore, the deep sleep current should be around 5 uA following its data sheet.
substitutions:
gpio_spi_clk_pin: GPIO13 #yellow
gpio_spi_mosi_pin: GPIO14 #DIN and blue
gpio_cs_pin: GPIO15 #orange
gpio_dc_pin: GPIO27 #green
gpio_reset_pin: GPIO26 #white
gpio_busy_pin: GPIO25 #purple
#ePaper HAT PWR pin connected to 3.3V of ESP32 as well
#Deep sleep configutation####################################
run_time: 40s
sleep_time: 120s
###other esphome standard code
# Deep Sleep ###################################################################################################
deep_sleep:
run_duration: ${run_time}
sleep_duration: ${sleep_time}
captive_portal:
spi:
clk_pin: $gpio_spi_clk_pin
mosi_pin: $gpio_spi_mosi_pin
font:
- file: 'fonts/Comic Sans MS.ttf'
id: font1
size: 40
#ePaper display 7.5in v2 800x480 #####################################################################################################
display:
- platform: waveshare_epaper
cs_pin: $gpio_cs_pin
dc_pin: $gpio_dc_pin
reset_pin: $gpio_reset_pin
busy_pin:
number: $gpio_busy_pin
inverted: true
model: 7.50inv2 #800x480
rotation: 0°
update_interval: never #so that it only updates one time after ESP32 wakes up from deep sleep
auto_clear_enabled: True
reset_duration: 200ms
id: epaperdisplay
lambda: |-
it.printf(155,295, id(font1), TextAlign::BASELINE_CENTER, "Hello World");