Arduino power on/off using MOSFET

Thread Starter

circuitdiver

Joined Nov 13, 2020
18
I was initially looking at a similar circuit where the latch pin would need to stay high. The disadvantage of that is that the momentary switch needs to be held for a couple of seconds to let the arduino turn on and set the pin high. The advantage of the circuit that cozendey posted was that it did not rely on the latch pin to keep it on and so the button press could also be short. I was able to get the circuit working that relied on the latch pin (we'll call that the sghioto circuit), but I couldn't get the cozendey circuit to work. Cozendey had a video demonstrating it and it made sense to me, so I was just assuming that I hooked it up wrong on the breadboard (although I checked it several times over). The sghioto circuit is not bad and I can use it if I need to, but I do think the cozendey circuit is more ideal for my use case. I do appreciate your input and your changes definitely take me from a state of "not working" to "working", which is very helpful.
 

sghioto

Joined Dec 31, 2017
5,392
momentary switch needs to be held for a couple of seconds to let the arduino turn on and set the pin high.
[/QUOTE
Why such a long time? The first line of code should set the pin high.
So what was the problem before when you had 5 volts present when the switch wasn't pressed?
 

Thread Starter

circuitdiver

Joined Nov 13, 2020
18
The first line of code did set it high, but the arduino is slow, so it took a couple of seconds to "boot up". I imagine that a faster MCU would run the first line faster and this would be less of an issue, so I'll probably go this route. The problem I had with the cozendey circuit is that the switch was irrelevent. As soon as I supplied power, the output to the arduino was 5V, but it should have waited for the button to be pressed.
 

Cozendey

Joined Mar 9, 2021
12
You could also try to put a diode just after the +5V, pointing towards the P-channel mosfet, so that the power supply can never act as a ground activating the p-mosfet, even if there is some transient state when it becomes on.
 

sghioto

Joined Dec 31, 2017
5,392
I tested the circuit on my breadboard and it works fine without the cap and the 10K resistor on the N channel mosfet.
Are you sure you have the P channel installed correctly or have the N channel where the P channel goes?
What is the part # of the P channel?
 
Last edited:

Thread Starter

circuitdiver

Joined Nov 13, 2020
18
The description on both of them says "...so you can control it directly from a microcontroller running on 5V logic.", so yes, I did think I it would work on a 5V MCU. I realize that their maximums are overkill, but what spec is not going to work with the Arduino? These work with the "sghioto circuit". I've triple checked that the mosfets are in the correct location (not mixed up).
 

Cozendey

Joined Mar 9, 2021
12
I think mosfets with lower specs would be a good bet, too. These power transistors would be a better fit for the part that there is 12V involved.
 

Thread Starter

circuitdiver

Joined Nov 13, 2020
18
I have some lower spec ones coming in the mail in the next couple of days. These from adafruit are all that I had on hand.
sghioto - what did you have in mind? Maybe I should wait until I get the others in the mail and if I'm still having issues, I can let you know.
 
Top