Latching Power (using digital pin out to power transistor)

So... I'm using my arduino to be a low voltage cutoff for my 12v deep cycle battery.

I have the voltage detection stuff sorted out and it works great.

My current problem is cutting EVERYTHING off of the battery once it breaks the threshold voltage. (11.5v under load is what I've decided on for now)

Would this work? Basically, the momentary button feeds 12v into the Vin on the arduino (so it goes through the arduino's vreg), which powers it on, then the sketch sets a digital pin HIGH which feeds into the base of an NPN transistor, which is connected between the ground pin on the 5v voltage regulator and ground. To cut power from everything, including the voltage regulator itself, I figured just set the digital pin to LOW.

I saw two issues. One issue being that the transistor might float. It's why I put that pull down resistor in the picture. Would that work? Set the pin to LOW, so the pull down resistor pulls the base of the transistor LOW, cutting the voltage regulator from the ground.

Second issue is that I'm not sure what weird things might happen for the brief period of time where the momentary button is providing 12v straight from the battery to the Vin on the arduino, and at the same time, the voltage regulator starts providing 5v to the 5v pin at the same time. I don't imagine it would cause problems, but just incase, I put that diode in there. (not knowing if it'll really do crap or not)

How does this schematic look for latching power? (with the ability to have the arduino power itself, along with a voltage regulator, off.)

(go easy on me, I'm a wanna-be amateur)

Have you considered using a latching relay?

Or purchasing a ready-made solution...

I suppose it's probably a cleaner and more efficient fix than what I would probably be able to make myself. (though not as fun as venturing into the unknown and attempting to make my own)

Thanks!

Your solution is flawed in two minor respects:

  1. The arduino's bootloader takes a few seconds to run, so you would need to hold the button in until it boots up.
  2. The NPN transistor would impose a 0.7v drop on the ground connection to the voltage regulator. This would move the ground reference by 0.7V giving you an increase of 0.7V on the 5V output. This 5.7V would be outside the 5.5V maximum for the Arduino, and could cause it to go pop.

Personally I would use a P-channel MOSFET as a high-side switch to control the power to devices, and switch them using an NPN transistor:

The FET is normally in the "off" state by the 10K pulling the gate up to 12V. Turn on the NPN and it pulls the gate to ground, switching the FET on.

If you connect your power button from the gate to ground, then pressing that button will force the FET on, thus providing power to the circuit. The NPN's base could be driven by the now powered on portion of the circuit through suitable resistance, so that the FET remains on when you release the button. A second NPN could then be controlled by the Arduino to pull that base below the switching level and turn the transistor off, thus turning off the FET.

Here's a Falstad link to a simulation: http://falstad.com/circuit/... (note: requires a java enabled browser).

platch.png