Post topics, source code that relate to the Arduino Platform

User avatar
By shoelessone
#54122
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!
User avatar
By shoelessone
#54124
picstart wrote:Assuming time is an issue when trying to catch a button press then a simple RC circuit ( button switch discharges the cap) with an appropriate time constant could be a solution...it also aids debouncing the button press.


I think I roughly understand what you mean, but any chance you could describe what you mean here? High level I imagine it's sort of like "caching" your button press - the button press somehow charges a capacitor that takes "longer" to discharge and that gives the delay needed to let the esp boot / be ready to read an input. Is that the idea? If so, how would I determine which button was pressed?
User avatar
By shoelessone
#56486
danbicks wrote:Simple circuit attached, allows 3 buttons, value are specific. Hope this helps.
Remember to add 10k resistor from spare GPIO to CH_PD to keep active while functions are performed.

AD Buttons CH_PD.PNG


Regards Dans


So I'm going to ask a stupid question, because I'm finally getting back to looking at this and breadboarding this up... but wouldn't the analog pin read basically "nothing" because there is a 220k resister sitting in front of it?