Power switching with a transistor

Hello!

I am trying to make an on/off switch for my entire arduino project.
I would like to use a button to turn it on, and turn it off with software.
My circuit is attached (the transistor is NPN).

However, as soon as the button is released, the circuit dies again.

My Vbatt is 5.15v. My Vout is only 5.09v. The microcontroller pin is showing even less.

I think the issue is that this system is a negative feedback loop, dropping voltage very quickly until the BOD activates, cutting it off…

Any help?

power sys.png

First of all, if it switches on with a connection to battery +, then it is NPN. But NPN cannot be used for high side switching. So this will not work in general.

Have you considered just using standby and use the button as an external interrupt? If done right, you can get the power well below the self discharge rate of the battery. If you have other periphery, you can then switch that on with a MOSFET controlled by the Arduino. Another advantage of that is that your device is available much faster - with the right settings in about 6 clock cycles, that is less than 1µs at 8MHz, so it can even read an I2C signal that woke it, in other setups.

You need a more complex circuit since the switch must latch - my favorite is to use a CMOS flip-flop that's permanently powered to switch a logic-level p-FET. The Arduino can pulse the reset input to the flip flop to turn off, the push button pulses the set-input.

Set-reset flip-flops can be constructed from 2 NORs or 2 NANDs, and there are several varieties of pre-built flip-flop in the 74HCxx series you can use too.

You could use e.g. a SN74LVCG00 dual NAND to built a flip-flop like this: http://www.elektronik-kompendium.de/sites/dig/0209302.htm

But since the datasheet states up to 10µA consumption, you are just as well off with a sleeping ATMEGA. Of course, you would have to go for a Pro Mini or standalone then, because the normal boards take too much current on other ends.