Transistor to Keep uC Power ON

I am trying to have a switch (momentary) on a remote, that will send power to the LDO. But as the switch is momentary, the power will be disconnected.

Can I have a transistor or some Mosfet to keep the power on, via the microcontroller pin, once the microcontroller is powered on.

This way the microcontroller can cut the power once done, and whenever the button is pressed, the microcontroller can keep the power on, until work done, or another button is pressed.

Is there any example circuit for the same, or any better way. On/Off switch is not possible, due to design constraints.

  • \$\begingroup\$ Question - What state will "uC 3.3V pin" be when the power is disconnected. Will it be able to pass a trickle of current??? Would be problematic if that happened. I'm thinking micro-amps to nano-amps could turn that transistor on enough to cause issues. \$\endgroup\$
    – Kyle B
    Mar 23, 2021 at 20:37
  • \$\begingroup\$ Add --- BTW, you drew this with an NPN transistor. You need to use a PNP in a "pass transistor" role such at this.... \$\endgroup\$
    – Kyle B
    Mar 23, 2021 at 20:38
  • \$\begingroup\$ When the microcontroller is switched off, the uC 3.3v pin would be low, I guess GND or floating. \$\endgroup\$ Mar 23, 2021 at 20:49
  • \$\begingroup\$ How to use a PNP transistor here, I didn't understand \$\endgroup\$ Mar 23, 2021 at 20:49
  • 1
    \$\begingroup\$ That's was my idea, didn't know what to search, so just created a dummy sketch. This is not an actual circuit, looking for better actual circuits. Now I know, its called with multiple names: auto power off circuit, latching power circuit, soft touch switch. Found a circuit on internet: randomnerdtutorials.com/…, I think this is what I am looking for. Or may be anything much easier than that, I don't think I need a 24Amps mosfet, need a find the cheapest mosfet or another simple circuit. \$\endgroup\$ Mar 23, 2021 at 21:05

2 Answers 2


The basic idea is good, but:

  1. For high side switch use PNP (or P-chan) driven with NPN. With your design you will push to LDO 2.6V only.
  2. The button press must be longer then LDO start-up time + charging filters time + boot time of MCU + time to set pin high. Set MCU fuse to startup as fast as possible and place setPinHigh() code very close to beginning can help you.

enter image description here

  • \$\begingroup\$ Actually point 2 is not an issue, as I want to hold the switch for some duration to turn on, to avoid accidental start, as it will be used by kids. So don't need touch to start. \$\endgroup\$ Mar 24, 2021 at 3:12
  • \$\begingroup\$ Can I add another button, between the R3 and Q1 connected to GND, to turn of the device. I don't want to waste a microcontroller pin. As this is embedded device, nothing to save, hard shutdown should not be a problem. \$\endgroup\$ Mar 24, 2021 at 3:18
  • \$\begingroup\$ Place the turn-off button between Q1 base and GND is a good aproach, but think about how long will MCU live from capacitor filters. In sleep mode it can be even many minutes, depends on sum of load. Also MCU hard reset/turn-off can lead to program malfunction, so you must count with the "reset can come anytime" when you write a code. \$\endgroup\$
    – user208862
    Mar 24, 2021 at 3:33
  • 1
    \$\begingroup\$ Btw, for turn-on button there is a better place than bridge Mosfet. Bridge Q1 from collector to emitter rather. Or even better sulution is from Vin to Q1 base - that however needs additional curcuitry to protect MCU_pin from overvoltage. \$\endgroup\$
    – user208862
    Mar 24, 2021 at 4:47
  • \$\begingroup\$ i2.wp.com/randomnerdtutorials.com/wp-content/uploads/2018/09/… I go with this design, as this is what you are saying, the additional circuitry is just pair of diodes. \$\endgroup\$ Mar 25, 2021 at 20:59

Like this, it won't work out.

An easy way to achieve this:

  1. Build a latch out of (typically two) transistors that you latch on with your button
  2. Turn off the latch using your microcontroller and a third transistor, typically.
  3. (optional, but strongly recommended) don't try to feed your regulator through your transistors. Instead, buy a regulator with an "enable" pin. Then, the regulator can be part of the latching itself.
  • \$\begingroup\$ Can you explain with a circuit, about the 2 transistor method, and also can recommend a suitable part with enable pin, that is almost same price as good old AMS1117 \$\endgroup\$ Mar 24, 2021 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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