A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By Barnabybear
#29198
eduperez wrote:Can the "simple push button" diagram be easily adapted for a "pull button" (i.e., to activate the ESP when a circuit opens)?


Hi, the easy answer is yes, but it’s not that simple to do in the spirit of the concept. i.e has very little power usage when powered down & doesn’t use lots of components.
That said, I’m guessing it would be good to adapt this to use normally closed contacts (standard alarm door contacts).
My first thoughts:
The easy answer – use the PIR example and replace the PIR with a 1k ohm resistor between Vcc and the diode & put your normally closed switch between the diode & ground. This will work for testing but hammer your batteries. If you go much more than 1k ohms you risk not having a logic 1 at CH_PD.
The maths bit:
When the switch is open (activated) the circuit is:
1K ohm resistor -> Diode -> 10K resistor.
Logic 1 = <0.75 VCC, So 75% of 3.3V = <2.47V (we need more than 2.5V at CH_PD).
Vcc = 3.3V - diode volt drop 0.7V = 2.4V (no head room so you’ll need a diode with a low forward volt drop).
If you use a diode with 0.3V forward volt drop.
Vcc = 3.3V – diode volt drop 0.3V = 3.0V (now we have some head room to play with).
We have 3.0V left to play with so we can work out the voltage divider with as high a value in series with the switch as possible to limit the power consumption during power down, but still give us <2.47V at the terminal.
10K + 1K = 11k (total voltage divider resistance) = ratio 10 to 1.
3.0V ratio 10 to 1 = 2.7V to 0.27V
We end up with:
3.3V (Vcc).
- 0.27V = 3.06V (after volt drop across 1K resistor).
-0.30V = 2.76V (after volt drop across diode & the voltage CH_PD will see).
-2.70V = 0.00V (after volt drop across 10K resistor & the rounding up of values).
The down side:
When the normally closed switch is closed (ESP is off & circuit is supposed to draw no power) there are two parallel circuits:
1k -> to ground via the switch.
Power = V / R, =3.3V / 1K = 3.3mA
1K -> Diode -> 10K to ground.
Negligible.
So with passive components, yes it can be easily done. But you’ll end up with about 3.3mA current draw even when powered down. I’m guessing this would be ok for development but is going to be no good for a final design using batteries.
We need to go back to the simple switch idea and find a way to invert your normally closed switch without using any power.
I feel another FET coming on. But not tonight.
User avatar
By Barnabybear
#31924
Vincent Lê wrote:On your last schema, I think the resistor connecting GPIO0 to the ground is wrong, it will keep GPIO0 to LOW, as of CH_PD

Hi, when the swith is closed (on) GPIO 0 and CH_PD will both be connected to 3.3V, so both high
Then the first line of your code needs to set GPIO 0 high
When the switch is opened (off) GPIO 0 will keep CH_PD high
GPIO 0 -> 1k resistor ->CH_PD -> 10K resistor -> GND
1K + 10K =11K
3.3V / 11K = 0.3V
GPIO 0 (3.3V) ->1K resistor -> CH_PD(3.0V) -> 10K resistor -> GND
CH_PD = 3.0V


When your code has finsihed it sets GPIO 0 low
The ESP will power off