First time poster, apologize if I accidentally missed any rules.

I've built a circuit that keeps a relay closed that is attached to battery power for a specific amount of time so my Raspberry Pi has time to shutdown.

I followed this circuit as guidance Shutdown Controller for Raspberry Pi in a car.

Somewhere though something is going wrong. When the circuit is assembled on bread board and I use a bench supply it will run for approximately 30 seconds. This would be a perfect amount of time for the Pi to run through its shutdown sequence. I even upped the capacitance a bit and was able to get a full minute of time which would hopefully give the Pi time to start and shutdown if the power was inadvertently turned on for a short amount of time.

When I install the circuit in the car however things go wrong. The circuit will only last 15 seconds no matter what size capacitor I run. I've run the meter all over the vehicle trying to figure out what might be causing this and can't find anything for the life of me. Putting the meter on the gate of the MOSFET and ground I can watch the Voltage drop to 3V from 12V almost instantly whereas on the bench it takes a longer time. This is with 2x 1,000 uF capacitors in parallel. Originally for the 30 second setup I was using a 470 uF capacitor. No matter what though the relay will always lose it's field and end up open in about 15 seconds. with the 2,000 uF worth of capacitors on the bench it will last well over a minute.

At first I was thinking maybe the car has something that is cutting either battery power or ground to the car stereo wire harness where I spliced in. Some sort of fail safe other than a fuse. I kept the meter on each of the separate wires during the sequence and Batt always stays about 11V, IGN obviously falls off when IGN is turned off, and GND always keeps continuity with the chassis.

The only possible thing I can think of being different between the car's power system and the bench supply is the ground. Do I need a resistor between the C1/R1 loop and ground? What's the difference in the ground symbols in the diagram I referenced?

  • \$\begingroup\$ The ground on the far left is chassis ground. The ones on the right are the Pi's circuit ground. They need to be connected somehow for the circuit to work. \$\endgroup\$
    – MattyZ
    Commented Oct 6, 2013 at 9:06
  • \$\begingroup\$ Not sure exactly what the problem is, but as an aside you should note that the circuit as shown is not safe for devices connected to it. There can be large positive and negative voltage spikes on the battery terminals, and as shown these will be coupled right into the regulator and your device. There needs to be transient suppression of some kind added after the relay. \$\endgroup\$
    – MattyZ
    Commented Oct 6, 2013 at 9:09
  • \$\begingroup\$ My understanding was that the regulator handled these spikes? I'm not running any kind of DIY circuit for the regulator I'm simply using a 12V - 5V USB regulator I found online meant for automotive applications. \$\endgroup\$ Commented Oct 7, 2013 at 20:04
  • \$\begingroup\$ Are you running the circuit under the same load on the bench? the load will figure into the time equation and heavily affect the outcome. \$\endgroup\$ Commented Sep 24, 2014 at 16:34
  • \$\begingroup\$ Also note that the 1N4148 diodes shown in the linked circuit are small signal diodes (low current). These are not the best parts to be using in automotive power circuits. (The answer mentioning a possible bad diode may have merit.) Use diodes of 1N400X series or better for this application. \$\endgroup\$
    – Nedd
    Commented Feb 5, 2015 at 7:28

3 Answers 3


I don't have an answer but do have a suggestion: Are you absolutely positive that your +12V rail is always live? Many vehicles disable what would be considered to be the main 12V rail anywhere from 10 to 60 seconds after the vehicle is shut off.

Second suggestion: a series resistor on the FET gate with a 12V zener diode clamp connected right between Source & Gate. The value of the resistor isn't critical because it's after the timing capacitor. Anywhere from 1k through 22k is good - I'd be using 4k7.

I regularly see significant transients on vehicle power rails. Some of that comes from what is called "Load Dump", where a heavy load is suddenly removed while the engine is running and the alternator voltage regulator can't respond quickly enough. That's only one source of high-voltage transients, there are others.


Are you testing the same circuit from the car on the bench setup? Any chance you static zapped the Mosfet in the car?

Notice that when you carry the circuit out to the car the Drain pin is completely floating on its own. Then when you then connect the first wire up to the car system you have effectively pulled all the static accumulation out of that side of the circuit. If you are contacting any part of the circuit any static charge on you will try to go to the car ground. When you go to make the next car connection you could also be putting a static charge onto another part of the circuit which tries to reach ground.

For example connecting the circuit ground first grounds the Source and Gate pins of the Mosfet. Then if the next thing you touch is the wire to the Drain pin any static charge on you could zap the Mosfet. Connecting the Drain wire to the car first could cause a static zap in the opposite direction if you then physically touch the ground of the circuit.

Car interiors are notorious for generating static charges, and discrete Mosfets are notorious for being destroyed by static zaps. Also with repeated testing of the circuit in the car you could have physically touched part of the circuit with one or more of the other leads disconnected.

Verify the Mosfet in the car circuit is still good. Swap it for a new part if possible. Even a small static zap could cause a Mosfet to function erratically. If you believe static was the problem you could add a bit of protection by adding a high value resistor from the Drain to Source points (then install the Mosfet last). A small value cap at the same position could help to. A high value resistor will bleed off any static charge that tries to accumulate. A cap or resistor will also reduce the voltage spike from a static zap.


Place a diode before the capacitor.


Probably something before the capacitor (in the source) is draining the capacitor.

If you have a battery and a capacitor in parallel, and drain energy from this, the capacitor will discharge faster than the battery, due to the internal resistences on the path and the internal resistence of the battery. I dont know if this can account for such quick shutdown. A diode would prevent that something before the capacitor, in the path from the battery, is allowed to drain the capacitor backwards.

  • \$\begingroup\$ If you have a capacitor and battery in parallel they will discharge together. They will both have the same voltage across them. If the battery holds up it will keep the capacitor voltage up too. \$\endgroup\$
    – Transistor
    Commented Apr 29, 2015 at 18:36
  • \$\begingroup\$ You are thinking in terms of ideal circunstances. For example, you assume that the electrons that compose the electrical charge can flow at infinite speeds from the battery to the capacitor. You are ignoring the impedance of the circuit between the battery and the capacitor. And in that specific case, you are ignoring that something might be draining a lot of power in the circuit, a situation in wich the diode will avoid that the capacitor to be discharged by something else that is not the relay that he wants to power etc. \$\endgroup\$
    – Jorge Aldo
    Commented Apr 29, 2015 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.