Raspberry Pi Advanced Soft On/Off Circuit

To purchase a completed board or to get a BOM so you can make your own, visit the store page here.

Like the simple on/off circuit, this is based around the IRF7319 dual mosfet. This is not the only mosfet capable of performing the duty, but it has characteristics that make it well-suited. Also, like the previous circuit, the +5v leading to the Pi is switched on and off. This is compatible with any power source.


A momentary press of the power switch will latch the circuit on and provide power to the system. The circuit is stable once latched on.

From here we need a way to power the system off, and the first method is built into the circuit. Pressing and holding the switch for about 5 seconds will drain Capacitor C3 and disable the N-channel MOSFET M2, which in turn disables the P-channel MOSFET M1 and kills power to the system. Of course, this should normally only be done after the Pi OS has been properly shut down.

We need something more automatic though. The circuit needs to power off automatically once the OS shuts down. This is done using the M3 MOSFET. In my design, it consists of a P-channel MOSFET with its gate connected to GND using Resistor R5. This keeps the MOSFET active, meaning it begins draining C3 as soon as the circuit is latched on. This forces the system off after 5 seconds unless the gate of M3 is pulled high. This is where the PI-OFF pad comes in.  In the circuit, the pad called PI-OFF is connected to the gate of a MOSFET, and connects directly to the TX pin on the Pi. This pin is typically used for serial data communication, but it has some characteristics that we will make use of here. Within a couple seconds of powering on, the OS automatically switches the TX pin to 3v3, and this pulls the gate of M3 high which disables M3. The TX pin remains at 3v3 until the OS has fully shut down. Once the OS shuts down, R5 pulls the gate down to ground again and enables M3. This causes C3 to begin draining and within 5 seconds the system powers off.

Advanced Feature:

One additional great feature to have is the ability to shut the Pi off using a pushbutton switch. Even better than that is the ability to shut the system down using the same button that turns the system on. With a small addition, this circuit can be used for both the power-on and power-off. One diode is added between the momentary switch and the P-channel mosfet gate, and the other diode is added between the momentary switch and a GPIO pin. I recommend the BAT54C Dual Diode because of its small size. The PI-SENSE pad connects to a GPIO pin and is used to issue a proper shutdown command. This requires a software component (guide will be made when I finish the PSPi PCB) to look for a momentary press of the power button. The GPIO pin is pulled high to 3v3 with the internal resistor. When the button is pressed, the GPIO pin connects to GND and causes a voltage drop on the pin. The software detects this drop and issues the shutdown command. Once the shutdown completes, the remaining circuits explained previously come into play and cause a complete shutdown.

Advanced Feature 2:

It’s also possible to use the same GPIO pin for both the PI-SENSE and PI-OFF features. This is somewhat more advanced and doesn’t really add anything other than additional complication unless the TX pin is needed for another use.

Questions? Comments? Leave a reply or visit the forum.

7 thoughts on “Raspberry Pi Advanced Soft On/Off Circuit

    • November 4, 2016 at 6:03 pm

      The TX pin automatically does everything needed for power on and power off. If you want the OS to do a shutdown when the button is pressed for a moment, then some Python code needs to be run in the background.

  • November 11, 2016 at 9:16 am


    first: thx for the great work. I learned so much from your tutorials.
    I try to make a handcrafted board based on your scheme that fits in a SNES controller. I wonder why my layout only got 5 pin outs and yours got 7. Where are these two extra pins come from?
    For my SNES project, i use a powerboost 500c lipo charger. Is there an easy way to integrate the charger into your circuit to cut power supply completely when the Pi shuts down?


    • November 11, 2016 at 9:59 am

      I’m trying to figure out exactly what you are asking.

      If you are trying to use the advanced on/off circuit, I recommend using a PCB since it has a large number of components (I’ll have this available to all countries soon). If you want to go the simpler route, the soft on/off circuit is much easier to assemble. This circuit goes between the output pins of the 500c and the input pins of the Pi, and it turns off completely when the OS shuts down. I hope I answered your question. Feel free to respond if you still are having trouble.

      • November 11, 2016 at 10:47 am


        sorry for my bad English.

        I try to use your advanced on/off circuit scheme to create my own PCB. The only thing I’m wondering is, why are there 7 pins on your PCB you are selling in your shop and not just 5?

        Since I am using a lipo charger, I also try to figure out how to not only shut down the PI but also the lipo charger itself (https://www.adafruit.com/product/1944). The charger cuts power when a pin (EN) is set to ground. Maybe you got an idea… but you don’t have to 🙂


        • November 12, 2016 at 11:03 am

          Okay I understand now.
          Pin 1: +5v in from the power supply
          Pin 2: GND in from the power supply
          Pin 3: Switch
          Pin 4: +5v out
          Pin 5: GND out (not needed, but included for anyone that wants it)
          Pin 6: Goes to TX on Pi
          Pin 7: Goes to GPIO on Pi for software shutdown

Leave a Reply