[Guide] Graceful shutdown switch without Pololu [RETIRED]
Re: [Guide] Graceful shutdown switch without Pololu
I had it working. Same schematic but with drain and source flipped. I'm using the 2N5460, ordered from Aliexpress. I also added a logic level converter to boost the keep_alive signal from 3.3V to 5V. That way the gate of the JFET receives a higher voltage and has a higher drain to source resistance. I think that J270 JFET can be a better option because it has a lower Vgs(off). I ordered some units. I'll update in about two weeks, after receiving them.
You must run the python power monitoring script for it to work. The script listens to the shutdown pin, when the pin is pulled down the system shuts down.
After a while the shutdown GPIO failed and was stuck at 0. I couldn't turn the gbz on because it shutdown immediately after startup. I mounted the file system on Windows and disabled the power monitoring script on boot.
Now I have an idea to overcome the problem by using the Arduino keyboard. I'll connect the shutdown signal to the Arduino which will send a special key to the pi via USB. The power script will shutdown the system upon receiving this key.
You must run the python power monitoring script for it to work. The script listens to the shutdown pin, when the pin is pulled down the system shuts down.
After a while the shutdown GPIO failed and was stuck at 0. I couldn't turn the gbz on because it shutdown immediately after startup. I mounted the file system on Windows and disabled the power monitoring script on boot.
Now I have an idea to overcome the problem by using the Arduino keyboard. I'll connect the shutdown signal to the Arduino which will send a special key to the pi via USB. The power script will shutdown the system upon receiving this key.
- KrxXxiT
- Posts: 25
- Joined: Sat Jun 18, 2016 3:13 am
- Location: Croatia
- Has thanked: 27 times
- Been thanked: 6 times
Re: [Guide] Graceful shutdown switch without Pololu
RxBrad wrote:I think I may have spent $30 on various online orders of parts trying to get this switch alone to work. At this point I feel obligated to get it working.
Who has gotten it working besides Camble?
(If you could post a working Fairchild FET diagram, @Camble, I think a lot of us in the States would appreciate it. That seems to be all we have available this side of the pond.)
I have the same transistor as Camble (Vishay Siliconix with this logo on it

I think I'm having problems because I'm trying to squeeze it onto such a small pref board and doing something wrong, so many times I crossed the wrong wires because I forgot which direction things were going when looking at it from upside down (when soldering the bask side).
Today I will try again, but laying everything out on a bread board and labeling my wires so when I need to try different combinations I wont mess something up.
If I manage to get it working, I'll post a detailed description, pictures, and a simple diagram.
I ordered one of @Camble's switches due to frustration, but I'll still try once more

- Camble
- Posts: 885
- Joined: Thu May 05, 2016 2:31 am
- Location: Scotland
- Has thanked: 269 times
- Been thanked: 488 times
Re: [Guide] Graceful shutdown switch without Pololu
@RxBrad The circuit is exactly the same, just reverse the Drain and Source. From the EN pin on the PowerBoost, you want your switch, then the Fairchild JFET Source. Then the JFET Drain goes to ground instead. Keep the 100K resistor across the Gate/Source and it should work.
@myPiZero I'd ditch the logic converter and use a GPIO pin other than GPIO4. See here.
@KrxXxiT I'm still considering doing a small run of through-hole PCBs with a kit of components, for anyone who wants a DIY solution without using perfboard.
If anyone is still having difficulty, jump on Discord. Send me an IM and I'll help if I can.
@myPiZero I'd ditch the logic converter and use a GPIO pin other than GPIO4. See here.
@KrxXxiT I'm still considering doing a small run of through-hole PCBs with a kit of components, for anyone who wants a DIY solution without using perfboard.
If anyone is still having difficulty, jump on Discord. Send me an IM and I'll help if I can.
Re: [Guide] Graceful shutdown switch without Pololu
@Camble you should place the resistor between the gate and the drain. The resistor discharges the gate when you open the switch.
Edit:
I got confused with MOSFET transistor in which the gate is actually a capacitor. In JFET you don't have that extra layer of oxide which forms a capacitor. I think you can get rid of that resistor.
Edit:
I got confused with MOSFET transistor in which the gate is actually a capacitor. In JFET you don't have that extra layer of oxide which forms a capacitor. I think you can get rid of that resistor.
Last edited by myPiZero on Sun Sep 18, 2016 2:18 pm, edited 1 time in total.
- KrxXxiT
- Posts: 25
- Joined: Sat Jun 18, 2016 3:13 am
- Location: Croatia
- Has thanked: 27 times
- Been thanked: 6 times
Re: [Guide] Graceful shutdown switch without Pololu
@Camble coolCamble wrote:@RxBrad The circuit is exactly the same, just reverse the Drain and Source. From the EN pin on the PowerBoost, you want your switch, then the Fairchild JFET Source. Then the JFET Drain goes to ground instead. Keep the 100K resistor across the Gate/Source and it should work.
@myPiZero I'd ditch the logic converter and use a GPIO pin other than GPIO4. See here.
@KrxXxiT I'm still considering doing a small run of through-hole PCBs with a kit of components, for anyone who wants a DIY solution without using perfboard.
If anyone is still having difficulty, jump on Discord. Send me an IM and I'll help if I can.

as we speak I'm setting my bread board and writing down wire colors and labels, will try to get this working

- KrxXxiT
- Posts: 25
- Joined: Sat Jun 18, 2016 3:13 am
- Location: Croatia
- Has thanked: 27 times
- Been thanked: 6 times
Re: [Guide] Graceful shutdown switch without Pololu
Since my last post, I've been testing and playing around with different configurations. I've made these diagrams to show what exactly I did.
Layout 02 seems to work but with the DMG switch behaving opposite of how it should. I'm thinking to just swap around the wires on the switch to get it to work the way it should.
Layout 02 seems to work but with the DMG switch behaving opposite of how it should. I'm thinking to just swap around the wires on the switch to get it to work the way it should.
Re: [Guide] Graceful shutdown switch without Pololu
In your diagram, if your switch is showing the off position, then yes it's wired backwards. Simply reversing the two pairs as you suggested should do it. What Jfet did you ended up using?KrxXxiT wrote:Since my last post, I've been testing and playing around with different configurations. I've made these diagrams to show what exactly I did.
Layout 02 seems to work but with the DMG switch behaving opposite of how it should. I'm thinking to just swap around the wires on the switch to get it to work the way it should.
circuit_layouts.jpg
- KrxXxiT
- Posts: 25
- Joined: Sat Jun 18, 2016 3:13 am
- Location: Croatia
- Has thanked: 27 times
- Been thanked: 6 times
Re: [Guide] Graceful shutdown switch without Pololu
Vishay Siliconix 2N5460. But on further testing it seems that layout 02 & 04 work similar.HoolyHoo wrote:In your diagram, if your switch is showing the off position, then yes it's wired backwards. Simply reversing the two pairs as you suggested should do it. What Jfet did you ended up using?KrxXxiT wrote:Since my last post, I've been testing and playing around with different configurations. I've made these diagrams to show what exactly I did.
Layout 02 seems to work but with the DMG switch behaving opposite of how it should. I'm thinking to just swap around the wires on the switch to get it to work the way it should.
circuit_layouts.jpg
It's strange, sometimes it turns off straight away after flipping the switch, other times it takes 2 or 3 seconds. Is this supposed to happen? Is this because of "sudo shutdown -h now" in @popcorn's code?
(What I wrote in red happened, then I tested again...)
I ran through all the layout's again. It's weird, all seem to work except for layout 04. Layout 04 shuts down as soon as I flip the switch, no matter how far along I am in the boot process and post emulation station startup, whereas all other layouts react differently depending on when I flip the switch.
For instance, when I flip the switch as soon as I flip it on, it shuts off instantly, if I wait to see some boot text onscreen then flip the switch, it waits until the boot process is nearly done then shuts down on its own, but sometimes when I'm in emulation station it shuts down as soon as I flip the switch, and sometimes takes anywhere between 2 to 10 seconds.
What is going on? I must be doing something wrong.
Is it possible that 3 out of the 4 layouts work?
I'm getting mixed results and it's frustrating, is there some log file buried deep in the system that I can check?
- RxBrad
- Posts: 278
- Joined: Fri Jul 22, 2016 9:10 am
- Has thanked: 125 times
- Been thanked: 160 times
- Contact:
Re: [Guide] Graceful shutdown switch without Pololu
@KrxXxiT
I tried all 4 of your diagrams with a fresh install of Retropie 3.8.1 (only adding the necessary dtoverlay=gpio-poweroff,gpiopin=22,active_low="y" config.txt change) on a breadboard with the Fairchild FET (noting that the Fairchild pinout is different).
Of note: #2 seems to match @Camble's most recent suggestion, while #4 matches what @myPiZero later recommended for moving the resistor. With all four choices, the power instantly cuts off when I flip the switch.
One interesting note: If I try to shut down the Pi Zero using the menus in Emulation Station, it does not shut down and I get a kernel panic. This happens on two completely separate Pi+SDcard+circuit setups. This happened even before I tried shutting down the system with the switch. One setup has Popcorn's script installed; the other doesn't.

I tried all 4 of your diagrams with a fresh install of Retropie 3.8.1 (only adding the necessary dtoverlay=gpio-poweroff,gpiopin=22,active_low="y" config.txt change) on a breadboard with the Fairchild FET (noting that the Fairchild pinout is different).
Of note: #2 seems to match @Camble's most recent suggestion, while #4 matches what @myPiZero later recommended for moving the resistor. With all four choices, the power instantly cuts off when I flip the switch.
One interesting note: If I try to shut down the Pi Zero using the menus in Emulation Station, it does not shut down and I get a kernel panic. This happens on two completely separate Pi+SDcard+circuit setups. This happened even before I tried shutting down the system with the switch. One setup has Popcorn's script installed; the other doesn't.

- RxBrad
- Posts: 278
- Joined: Fri Jul 22, 2016 9:10 am
- Has thanked: 125 times
- Been thanked: 160 times
- Contact:
Re: [Guide] Graceful shutdown switch without Pololu
@Camble @myPiZero
A couple times in this thread, I've seen mention of Python monitoring scripts and modifying Popcorns power monitor. Is Popcorn's script absolutely necessary? On the one of my setups that has the monitoring script installed, I thought I modified Popcorn's script as instructed, but now I wonder if I did it wrong. This seems to be the one point in the first post that's still kind of vague, and might be a source of a lot of people's problems....
A couple times in this thread, I've seen mention of Python monitoring scripts and modifying Popcorns power monitor. Is Popcorn's script absolutely necessary? On the one of my setups that has the monitoring script installed, I thought I modified Popcorn's script as instructed, but now I wonder if I did it wrong. This seems to be the one point in the first post that's still kind of vague, and might be a source of a lot of people's problems....
Who is online
Users browsing this forum: No registered users and 1 guest