1
\$\begingroup\$

I have built the following circuit to power my esp8266. And it works fine.

reference: https://community.home-assistant.io/t/multiple-button-wifi-remote-no-deep-sleep-required-battery-lasts-forever/306233

https://community.home-assistant.io/t/multiple-button-wifi-remote-no-deep-sleep-required-battery-lasts-forever/306233

When you press the button esp8266 turns on and by setting D1 high it has still power even the button is released. When I do things with my code I set D1 low and esp8266 shuts down.

But in my application when the button is pressed it will stay pressed for a period of time. I want esp8266 to be able to shut down all circuit whether the button is released or not. If user releases the button and press it again esp8266 should power on again.

But in this circuit if the button is still pressed after esp8266 does its job and set D1 low, the circuit remains powered.

What can I do to make esp8266 power down even button is still pressed?

I don't want anything with software, sleep mode etc, I need to solve this with electronics.

\$\endgroup\$
4
  • \$\begingroup\$ You most prob. fliped the logic in question. D1 low causes power on. \$\endgroup\$ Commented Dec 9, 2023 at 2:54
  • \$\begingroup\$ Regarding solution just trig the mosfet with short pulse from button, not the level. Simple RC will do the job. \$\endgroup\$ Commented Dec 9, 2023 at 2:58
  • \$\begingroup\$ @MichalPodmanický Can you give detail? What is RC? I am not good at electronics. \$\endgroup\$
    – Kerem
    Commented Dec 10, 2023 at 1:44
  • \$\begingroup\$ A series capacitor above the switch should do the trick. Just make sure that the digital output takes over before the RC time of the capacitor and your 100k runs out. \$\endgroup\$
    – Graafvaag
    Commented Dec 10, 2023 at 11:28

2 Answers 2

0
\$\begingroup\$

So you want the circuit to react to the edge, not the continuous state. This can be done by adding a capacitor between the switch and the node of 100k/gate/d1 (Let's call this Vg) right above it.

When you first press the switch, the capacitor is empty. This immediately pulls the node Vg low, enabling the FET just like before.

The capacitor starts charging up through 100k, and at some point it will reach the threshold voltage of the FET which will turn off again.

To make sure it doesn't, the RC time should be long enough for the ESP to boot and pull D1 low permanently.

The ESP can now disable the power regardless of the switch state.

The only thing to fix is resetting the capacitor. When the switch opens, the capacitor has one pin floating, so it doesn't discharge. To fix this, connect a resistor that is at least 10x the size of your 100k (so 1Meg) in parallel to the capacitor. The ratio of 1:10 ensures that it doesn't influence the rest of the circuit too much.

Try 1uF at first, the ESP will have several tens of milliseconds to boot. If it doesn't work, try 10uF.

\$\endgroup\$
0
\$\begingroup\$

Pulling pin Low you hold Mcu powered. Pulling High you disconnect supply. It’s good to add 10u + 100n bypass caps to Mcu Vcc so it live few ms after pulling pin High. A diode is signal schottky.

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.