Circuit for low-side MCU-controlled soft power switch? - Page 1
Forum section: electronics / beginners

author: Peabody
author_rank: Super Contributor
timestamp: November 21, 2019, 05:57:05 pm
content: This relates to the type of circuit in which a momentary pushbutton turns on power, and then the microcontroller takes over and keeps power on by asserting a GPIO pin - until it's ready to turn off its own power.The circuit on the left in the attached picture uses a P-channel mosfet on the high side to switch power. I've used it several times, and it works fine. But I wondered if there was a low-side equivalent using an N-channel mosfet. The circuit on the right is an attempt to do that, but I don't think it works.If the power is on, and the MCU attempts to turn it off by bringing the GPIO high, or making it an input, I think current will flow from the 9V rail through the emitter and base of the PNP, into the GPIO pin, and through the upper protection diode to 5V. If that happens, the PNP will stay on, and the MCU will be unable to do anything to turn it off.Am I thinking right about this? If so, how might this be made to work without adding another bipolar transistor? It seems that to make it really equivalent, you would have to move the regulator to the low side, and make it 4V - not something you see every day.

author: MarkR42
author_rank: Regular Contributor
timestamp: November 22, 2019, 10:19:51 am
content: I am reasonably sure that you can do the low-side switching without using a 2nd transistor, i.e. just use the mosfet.Provided it's the correct type of n-channel mosfet, i.e. the gpio is high enough to fully turn it on, then it should work. I've not tried that exact setup myself, but I have done low-side switching of other loads with a n-channel mosfet from a micro.

author: Peabody
author_rank: Super Contributor
timestamp: November 22, 2019, 04:40:37 pm
content: Quote from: MarkR42 on November 22, 2019, 10:19:51 amIf you mean just driving the mosfet gate directly from the GPIO pin, I don't think that will work if what you're switching is the MCU's own ground. If the positive rail is connected, but the processor's GND is not connected to the negative rail, then a GPIO pin will read as 5V, or 9V or whatever, with respect to the negative rail. And that will turn on the mosfet. So I think it would try to cycle on and off.

author: MarkR42
author_rank: Regular Contributor
timestamp: November 22, 2019, 08:19:15 pm
content: Maybe a weak pull-down resistor would enable it to stay off? Like a 33k or something?

author: Peabody
author_rank: Super Contributor
timestamp: December 04, 2019, 05:50:52 pm
content: I tested the attached circuit, and it seems to work fine. With the right mosfet, it also works on a 3.3V controller.

author: EEisBS
author_rank: Newbie
timestamp: July 18, 2025, 09:28:40 pm
content: Hi Peabody. I know this was years ago, but can you provide details into which PNP BJT, and which NMOS you used?I tried building the circuit using a BC557 PNP BJT and a 2N7000 N-MOS. The button works to power the Arduino, but does not latch in poweras is my goal.I'd appreciate any insight you can provide!

author: ledtester
author_rank: Super Contributor
timestamp: July 19, 2025, 12:07:53 am
content: Quote from: EEisBS on July 18, 2025, 09:28:40 pmFirst a sanity check... after powering up does your Arduino code make the GPIO pin an output and sets it to LOW? That's what is needed to keep the MOSFET on.

author: Smokey
author_rank: Super Contributor
timestamp: July 19, 2025, 03:12:42 am
content: Search "load switch" on digikey. Sort by "high side". Diode OR the microcontroller pin and physical switch voltages to the enable of the load switch.

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2025, 03:17:00 am
content: The PNP would have been a 2N3906. I don't know about the mosfet. It would need to be logic level, with a threshold voltage of maybe 2V or lower. I think the ones you used should work if you make the GPIO output low.

author: EEisBS
author_rank: Newbie
timestamp: July 21, 2025, 03:33:37 pm
content: Thanks for your replies. I did in fact have a silly error in my Arduino script. The circuit works perfectly to latch power into the MCU.Has anybody used (a version of) this circuit that allows the same button press to be used to de-latch power from the MCU?

author: tooki
author_rank: Super Contributor
timestamp: July 21, 2025, 04:45:08 pm
content: One approach is to add some diodes and resistors so you can use another GPIO to monitor the button state, and then when you detect a press, you can run whatever cleanup/shutdown code you need, and then at the very end, turn off the GPIO that’s holding it on. I’ve done this before, but set up the code so that simple presses change modes, and then holding down the button shuts down.