Suicide Controller

Hello I'm trying to figure out how to use a FET to cut off the power to an entire microcontroller project, including the controller itself.

What I've tried:

a low side MOSFET with a gate connected to an output pin. This doesn't work, I believe it's because as soon as the FET opens in the the gate is effectively connected to the ground of an ungrounded uC. This causes the gate to go back high and the controller just stays on permanently in equilibrium lke this

a low side MOSFET with the Source and Gate pins connected with a strong resistor, gate also connected to an I/O. The gate can be pulled high as normal to close the circuit. To open the gate I change the pinMode of the I/O to INPUT to dramatically increase its impedence, in the hopes that the gate will be pulled low by the resistor. This doesn't work either.

I've seen this done using relays but I would really like to implement this with a FET for smaller size and power consumption. My searching is flooded with variations of the "most useless machine" so it makes this hard to find. Thanks for your advice!

http://www.pololu.com/catalog/product/750

This should do the trick (check the attachment):

When I close the switch, current starts to flow through Q1 and Arduino powers up. Arduino’s pin 3 (OUTPUT-mode/HIGH) goes to the base of Q2. Current flows through Q2 and provides an other route to pull the base of Q1 to the ground. Now I can release the switch and the circuit stays powered up. When Arduino needs to cut off the power, it puts the pin 3 LOW. Q2 stops conducting, the base of Q1 is pulled up and no more power flows to Arduino.

I used transistors (BC640 and BC639) instead of FETs, but I believe it should work with FETs too.

I tested the circuit on a breadboard and it worked almost as I expected. The only problem was that I needed to press the switch for a couple of seconds until the circuit started to hold. I thought that it should start to hold almost instantaneously after I press the button.

Thanks for the help. I would prefer not to use to pololu switch so that I can put the circuit on my own PCB. I'll try out the suggested circuit ASAP and let you know how it goes!

pekkaa: I tested the circuit on a breadboard and it worked almost as I expected. The only problem was that I needed to press the switch for a couple of seconds until the circuit started to hold. I thought that it should start to hold almost instantaneously after I press the button.

That's probably because the bootloader has to time out before the Arduino runs your sketch and sets pin 3 high. If you will be migrating your design to a PCB, you can program the mcu via ICSP and omit the bootloader.

It worked! Many thanks for your help. Did you find this circuit somewhere or devise it yourself?

I designed it myself, but I am pretty sure that many others have figured it out countless of times before me. Glad to hear it helped you!