schufti wrote:due to "housekeeping" the esp is not the fastest to boot up. But in ~300ms it should be in your setup() and you should be able to check the button. Pressing a button for less than 300ms is pretty quick but hey, if you can't detect a presed button just go to sleep again.
the getResetInfoPtr() etc is code to determine what is the actual cause for the start, esp is pretty talkative about this: power up, watchdog, rst_pin, reset from deep_sleep, ...
shortly removing high on chpd (disregarding of former state) is the same as powering up,
aserting reset can be: just simple reset or wakeup from deep-sleep, depending on the former state.
Thanks for this, this makes great sense and is something I absolutely did not know! This seems super useful, and like perhaps a more "reliable" way to handle this problem, although it limits the number of buttons to the number of ways that the ESP can be woken up (as far as I understand it at least).
Assuming I go with a different approach, such as the first sketch which was basically using the analog input to check which button was pressed, a stupid question perhaps but at that point is there any reason that the esp needs to be in "deep sleep" vs just plain "off"? I guess this might sound stupid, but what is the difference in this situation between being off and being in deep sleep? Does it take less time to boot from deep sleep (i.e. there would be a better chance of "catching" the button press and reading the input pin?)
Thanks again!