Order doesn't matter as long as they have continuity when it's switched to their respective position. The two pairs are en,fet and with the change we talked about, ground and gpio 27 not the keep alive.RxBrad wrote:I can try later today when I'm back home.
Is there maybe an issue because I'm using a DPDT switch to test (the same one Camble recommends near the beginning of this thread)? I assume the pins are laid out similarly to the DMG.
On the top row, for the OFF position, I have GND and the FET attached to the 2 leftmost pins. (Does the order matter here?)
On the bottom row for the ON position, the keep alive GPIO and 3.3 volt are attached to the two rightmost pins. (Again, does the order matter?)
[Guide] Graceful shutdown switch without Pololu [RETIRED]
Re: [Guide] Graceful shutdown switch without Pololu
- 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
@HoolyHoo Whoops.. was working off memory, and messed up a couple pin names (fixed); but it sounds like the switch isnt the issue. I'll give your change a try when I get a chance...
- 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
@HoolyHoo
OK...
TEST #1
Starting with Circuit #2.
- Moved connection on the ON position of switch from 3.3v to a GND pin on the Pi. So, when the switch is powered on, GPIO 27 and GND should have continuity.
In the battery monitor script:
25. GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
64. if GPIO.input(powerGPIO) is 0:
87. if GPIO.input(powerGPIO) is 1:
Same change to config.txt specified at the beginning of the thread.
RESULT: Pi boots up normally. Does not instantly go into reboot on boot. However, power is cut instantly when flipping the switch off.
TEST #2
Same as above, but switch Drain & Source connections to FET. So, basically starting with circuit #1.
RESULT: Same as above. Flipping off the switch instantly kills the power.
OK...
TEST #1
Starting with Circuit #2.
- Moved connection on the ON position of switch from 3.3v to a GND pin on the Pi. So, when the switch is powered on, GPIO 27 and GND should have continuity.
In the battery monitor script:
25. GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
64. if GPIO.input(powerGPIO) is 0:
87. if GPIO.input(powerGPIO) is 1:
Same change to config.txt specified at the beginning of the thread.
RESULT: Pi boots up normally. Does not instantly go into reboot on boot. However, power is cut instantly when flipping the switch off.
TEST #2
Same as above, but switch Drain & Source connections to FET. So, basically starting with circuit #1.
RESULT: Same as above. Flipping off the switch instantly kills the power.
- 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
EDIT: The circuit below was very inconsistent. Turns out I'd been working with counterfeit FETs ordered here in the US. This explains why it sometimes worked using an incorrect pinout on the FET.
BREAKTHROUGH!!!!! (Urk. Most of the time, at least. It occasionally still insta-kills the power.)
In the battery monitor script:
In config.txt:
Wire it up like this:

It frickin' WORKS!!!! Tested with a Fairchild 2N5460 and a Fairchild 2N5461.
Reminder that this is the pinout on the Fairchild FET:

Link to Datasheet
(By all accounts this apparently shouldn't work. But it does. So, perhaps Fairchild published their pinout incorrectly.)
BREAKTHROUGH!!!!! (Urk. Most of the time, at least. It occasionally still insta-kills the power.)
In the battery monitor script:
Code: Select all
25. GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
64. if GPIO.input(powerGPIO) is 0:
87. if GPIO.input(powerGPIO) is 1:
Code: Select all
dtoverlay=gpio-poweroff,gpiopin=22,active_low="y"

It frickin' WORKS!!!! Tested with a Fairchild 2N5460 and a Fairchild 2N5461.
Reminder that this is the pinout on the Fairchild FET:

Link to Datasheet
(By all accounts this apparently shouldn't work. But it does. So, perhaps Fairchild published their pinout incorrectly.)
Last edited by RxBrad on Sat Sep 24, 2016 12:02 pm, edited 2 times 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
RxBrad wrote:BREAKTHROUGH!!!!!
In the battery monitor script:In config.txt:Code: Select all
25. GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) 64. if GPIO.input(powerGPIO) is 0: 87. if GPIO.input(powerGPIO) is 1:
Wire it up like this:Code: Select all
dtoverlay=gpio-poweroff,gpiopin=22,active_low="y"
It frickin' WORKS!!!! Tested with a Fairchild 2N5460 and a Fairchild 2N5461.
Reminder that this is the pinout on the Fairchild FET:
Link to Datasheet
(By all accounts this apparently shouldn't work. But it does. So, perhaps Fairchild published their pinout incorrectly.)
In the morning I will test this and confirm if right.

- 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
Yes... And I may have spoken too soon. It worked about a half dozen times, and now it's back to insta-killing power again.
I wonder if the keep alive GPIO isn't sending a steady reliable signal for some reason...
I wonder if the keep alive GPIO isn't sending a steady reliable signal for some reason...
- 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 Your drawing shows the Source pin of your JFET connected to GPIO22. This should be where the Gate pin connects to. The channel is between the Drain and Source, the Gate controls it.
- 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 What you say makes total sense. Fairchild may have released their datasheet with the pinout listed incorrectly(?) Which is probably why I've had so much trouble getting this working. This is literally the only way I've had even remote luck getting this to work.Camble wrote:@RxBrad Your drawing shows the Source pin of your JFET connected to GPIO22. This should be where the Gate pin connects to. The channel is between the Drain and Source, the Gate controls it.
- 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 No, just your drawing. Look at where the Gate connects to.
Also, I've checked that the amendments to line 64 and 87 of the script are not necessary (as long as you still have the switch connected to 3.3v).
You've hit this point where you're frantic to get it working. It's happened to me plenty. You need to take a step back, look at every single connection, and make sure everything is correct.
Also, I've checked that the amendments to line 64 and 87 of the script are not necessary (as long as you still have the switch connected to 3.3v).
You've hit this point where you're frantic to get it working. It's happened to me plenty. You need to take a step back, look at every single connection, and make sure everything is correct.
- 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
Those FETs I ordered finally got here from China. The ones from eBay with the Vishay logo on the auction image.
They're Fairchilds.
(╯°□°)╯︵ ┻━┻
They're Fairchilds.
(╯°□°)╯︵ ┻━┻
Who is online
Users browsing this forum: No registered users and 1 guest