Powering Off Arduino with P-Mosfet

HI, I am in the process of building a project (reverse geocache), and need a littte help with completely powering off my UNO board 10 (or so) seconds after a temporary switch has been pressed to power it on. I have read quite a few topics on here about it, but i cannot find one that answers my question exactly. I believe that a P-MOSFEt is what i need to use, but i need some help with wiring diagrams and sketch ideas please? Thanks :)

Look at this ciruit, from @CrossRoads

Tom… :slight_smile:

Hi Tom,
Thanks for that. Unfortunately, that schematic is a little confusing to me as I’m a real newbie and have only worked with simple projects so far.
What is the NPN used for?, and do those two resistors need to be added to the circuit or is one of them already incorporated into the MOSFET?
Also any chance of some coding to add to my sketch to make it all work please?

This is my sketch so far … (thanks to /dev for simplifying it)

Reverse_Geocache.ino (3.59 KB)

Hi, The explanation with the diagram explains.

The P-MOSFET is the switch, the NPN transisitor is used via the controller to hold the MOSFET ON after the button is pressed for a moment or to. Then in your code you tuen the NPN OFF when you need to power down, this turns the MOSFET OFF.

I am at work now, but later if someone hasn't helped you, I'll do a better basic explanation.

If you look up how a MOSFET works and a BJT that will help.

Tom.. :)

Thanks Tom .. that would be appreciated

What is the NPN used for?

When the switch is pushed, the NPN transistor (under program control) maintains a short across the switch. Therefore the P MOS FET stays on after the switch is let go.

When the sketch turns the NPN transistor off, the MOS FET removes power from the controller.

Thanks larryd, I have been looking at NPN transistors and P MOSFETs’ and have noticed many different voltage/amperage ratings. My UNO will only be powering a GPS module and a 16x2 LCD (a servo will be powered by a separate battery box). Not really sure which voltage/amperage i will be needing if i do purchase these two items?

You could have a look here, I used this in a project but added a slight delay in setup with a while loop so you had to hold the button for 1.5seconds to turn on, This was to prevent accidentall button presses and prevent wasting battery life. You can also use the auto turn off feature if required


Works on low voltage too.

Hi again guys, I have been playing around with different circuits that i have found on the net trying to get my project to power off 5 seconds after pushing a button, but have had no luck in getting it working. The roughly drawn circuit that TomGeorge had posted earlier, i can’t make sense of. I have both P-channel & an N-channel mosfets, as well as an NPN transistor at hand.

Can anybody help me with a decent diagram and some simple code please?

What are the part numbers that you have? Will this be driven by an Arduino?

The part numbers are : N-Channel - 30N06L P-Channel - NDP6020P NPN Transister - BC337 Yes, will be driven by an UNO

Watch this: https://m.youtube.com/watch?v=Foc9R0dC2iI

The schematic from #1 requires you to keep the button pressed for long enough time (1-2 seconds) for the Arduino to start up and activate the pin that keeps the NPN switched on.

There are ways to not need that delay, and give the Arduino the ability to switch itself off after some time. The easiest way to do that is in code.

If you really want to do the power part in hardware, use a 555 timer in monostable mode. Press the button and the output will go high for some time (depending on the RC constant you set), which then can turn on the Arduino, and switch it off again when time is up. The 555 will draw some current at all times, but this can be down to microamps or less, bringing it down to less than the self discharge rate of most batteries.

Hi, Can you show us the code you are using in the UNO?

Thanks.. Tom.. :)

int OnOffPin = 7;

void setup() { // initialize digital OnOffPin as an output. pinMode(OnOffPin, OUTPUT);

// initialize digital pin 13 to show when the OnOffPin is high pinMode(13, OUTPUT); }

void loop() { digitalWrite(OnOffPin, HIGH); // turn the OnOffPin on by making the voltage HIGH digitalWrite(13, HIGH); delay(5000); // wait for five seconds

digitalWrite(OnOffPin, LOW); // turn the OnOffPin off by making the voltage LOW digitalWrite(13, LOW); delay(5000); // wait for five seconds, but this should never come back on }

This project supplies a version of Crossroad's circuit I have had good luck with.



This may help;

Tom… :slight_smile:

Thank you .. ill give it a try. Where would be the best place to incorporate a momentary push button in this circuit?

Between the + and the EN (the push button has to take the task of the pin while the Arduino is still off). It'll also need a protection resistor on the pin (10k or so), as connecting the pin directly to Vcc while the Arduino is still off may kill the pin.

Try this: See post #21 below.