-->
Page 1 of 5

Clever but simple way to wake esp with multlple buttons?

PostPosted: Sun Aug 28, 2016 11:35 pm
by shoelessone
Hey all!

So I know this comes up every once in a while but I have yet to find a solid or concrete answer / solution, so here goes again!

In short: I want to wake a esp8266 from "deep sleep" so I can have it battery powered, but I want to do so with two individual buttons that will cause a different action to be performed depending on which was pressed. The question is how do I wake the esp8266 (CH_PD to high?) AND "tell" the esp8266 which button was pressed?

Bit more info:

I'm interested in having a battery powered esp8266. This will be a Christmas present for my little brother and sister (each will get a device). I will create a box, and I'd like it to have two buttons: Button 1, when pressed, will order a pizza and have it delivered to my parents house. Button 2 will check whether or not a pizza can be ordered at the time (I'm not rich so can't have them ordering a pizza every day!) and flash some status light to inform them one way or another (i.e. green led or red led, etc).

Waking the esp with a button press is pretty common and something I've done myself in the past, but most of the time what I've seen is that the button press simply wakes up the macihne and causes some action to be performed before cutting power and causing the eps8266 to go back to sleep. I.e. the button that was pressed isn't really being used as an input in anyway, it's just sending power to the ch_pd pin to wake the thing.

One thing I was wondering is if I could have two buttons: when pressed they would pull the ch_pd pin to high AND cause an input pin to be set high. The esp would wake and the second it woke it would read the state of the input pins. It would record the state, and once connected to wifi it would act based on the button press.

This seems "obvious", IF it worked, but I'm guessing that it may not be this simple (?).

I'm hoping to actually give this a short and do a proof of concept in the next few days or so, but I'm waiting on parts!

For now, thanks for reading and thanks for the help as always!

Re: Clever but simple way to wake esp with multlple buttons?

PostPosted: Mon Aug 29, 2016 3:07 am
by danbicks
Hi,

This is actually very easy to do. Use the analogue to digital converter input to read push buttons, potential divider style. with no buttons pressed the A>D should return max reading 1023 for 3.3v via a potential divider.
at the raw 3.3v side of the button matrix use this to feed a PNP transistor that apply's voltage to CH_PD and a spare pin on the I/O to hold CH_PD in this state, scan the A>D work out what button has been pressed and perform operation from here. As long as the base pin of the PNP transistor is bellow emitter by 0.7v the transistor will switch voltage to CH_PD.

Hope this helps, should be a walk in the park.

Dans

Re: Clever but simple way to wake esp with multlple buttons?

PostPosted: Mon Aug 29, 2016 4:33 am
by danbicks
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

Re: Clever but simple way to wake esp with multlple buttons?

PostPosted: Mon Aug 29, 2016 4:45 am
by schufti
nice idea but could even be solved with one button/led:
°) detecting long/short press and/or
°) just flash led fast if no credits available, flash led slow and order otherwise

I would strongly suggest to implement some saveguard like max. 1 order/day or suchlike...