Where can I find a safe shutdown script?

Having trouble with your GBZ build? Ask your questions here!
Doc105
Posts: 32
Joined: Tue May 02, 2017 12:00 pm
Has thanked: 1 time

Where can I find a safe shutdown script?

Post by Doc105 » Wed Apr 03, 2019 8:45 am

I don’t know if it needs special hardware but I was wondering how to do safe shut down? Thanks in advance :D

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: Where can I find a safe shutdown script?

Post by infinitLoop » Wed Apr 03, 2019 10:16 am

Doc105 wrote:
Wed Apr 03, 2019 8:45 am
I don’t know if it needs special hardware but I was wondering how to do safe shut down? Thanks in advance :D
i think that the easiest solution is to add a gpio button, and put this in config.txt (assuming pin 4 for this):

Code: Select all

dtoverlay=gpio-shutdown,gpio_pin=4
if you are looking for something more involved, like a toggle switch that does the shutdown and then powers off, you need to have a circuit to handle it with a mosfet gate, or something like that.

Doc105
Posts: 32
Joined: Tue May 02, 2017 12:00 pm
Has thanked: 1 time

Re: Where can I find a safe shutdown script?

Post by Doc105 » Wed Apr 03, 2019 11:59 am

Cool, thanks, could it be possible to run a toggle button through a teensy it has 5 volt output right?

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: Where can I find a safe shutdown script?

Post by infinitLoop » Wed Apr 03, 2019 12:44 pm

Doc105 wrote:
Wed Apr 03, 2019 11:59 am
Cool, thanks, could it be possible to run a toggle button through a teensy it has 5 volt output right?
hm, not in that way. that would work for a button straight to the gpio. when you use a teensy, or similar, you program it to pretend to be a usb keyboard input, and that's how its used as a controller. i haven't tried to point a keyboard button to the shutdown command, but it's probably possible (although, my guess is it's harder than just using the gpio).

but, it's at least as easy to solder the wires to the pi itself, so unless you're using all your pins, it still seems easier to go the gpio.

Doc105
Posts: 32
Joined: Tue May 02, 2017 12:00 pm
Has thanked: 1 time

Re: Where can I find a safe shutdown script?

Post by Doc105 » Wed Apr 03, 2019 1:04 pm

couldnt you still use the teensy in serial+keyboard? Then wire that to the gpio? Then have a separate pin outputting 5v? Sorry I’m kinda new to this stuff.

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: Where can I find a safe shutdown script?

Post by infinitLoop » Wed Apr 03, 2019 1:21 pm

pretty sure you shouldn't wire 5v from the teensy to a pi's gpio. the input pins are lower voltage, like 1.1v or something. enough to get on/off digital signals mainly. the 5v is your main power line. if you push 5v into the gpio pins that aren't the two that are labelled 5v, you're going to fry the pi (if it's a zero. the other models have some voltage protection, i think, but it's still a very bad idea).

as far as programming in keyboard + serial -- i dunno, maybe. i've only ever set up micro controllers to do keyboard, key press stuff. but again, it seems way harder than just wiring the button to the gpio, to have the micro handle it.

Doc105
Posts: 32
Joined: Tue May 02, 2017 12:00 pm
Has thanked: 1 time

Re: Where can I find a safe shutdown script?

Post by Doc105 » Wed Apr 03, 2019 1:58 pm

Yeah your right. (But for the record I was gonna run it throughout the dedicated 5v pins)

Doc105
Posts: 32
Joined: Tue May 02, 2017 12:00 pm
Has thanked: 1 time

Re: Where can I find a safe shutdown script?

Post by Doc105 » Wed Apr 03, 2019 2:14 pm

Here’s what I was thinking
UPDATE: just remembered shutting down and powering off are two separate things forget all of this
3BB3F119-CF59-4676-915C-04AEA1D3D80C.jpeg
3BB3F119-CF59-4676-915C-04AEA1D3D80C.jpeg (2.11 MiB) Viewed 5191 times

User avatar
infinitLoop
Posts: 536
Joined: Mon Dec 24, 2018 11:46 am
Location: Portland, OR
Has thanked: 222 times
Been thanked: 199 times
Contact:

Re: Where can I find a safe shutdown script?

Post by infinitLoop » Wed Apr 03, 2019 2:56 pm

right - if you want shutdown + power off, then that's something people have used gates for, or at least some kind of circuit. depending on the power supply you want to use, you might have some options around utilizing the "engage" pin too. the ones i've seen/used still use just the gpio for control though, and basically have one pin call "shut down" then another pin that stays active til the power down, and then that triggers it to cut the power.


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest