OpenMarine

Full Version: Shutdown button with moitessier hat
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to have the possibility to have a momentary pusch that can shutdown all the program and the raspberry.
In this way before turn off the power, i can shutdown the raspy in a very simple way.

I have set the moitessier hat and i don't know if there is some free GPIO that i can use for this purpose.

Thank you
what I understand, from the users guide of the moitessier hat, is that the gpio 5 and 6 of the rspi is not used by moitessier hat, so I can use one.

I found a modification of the config.txt file, that should be ok for my purpose:

Code:
dtoverlay=gpio-shutdown,gpio_pin=5

So I have to connect (soldering?) the temporary switch to gpio 5 and ground, modifing the config.txt file, and everything should work correcly.

Anyone can tell me if this is going to work or not?
I found a solution for my porpouse at thins link: https://bre.is/bDYg9gcsL

Everythings work great if i start the python script with the command

"sudo python3 shutdown.py"

How can i make the script loading directly during the startup, without have to lunch the program from the shell everytime?

Cheers
on your link Step 5: Activate On Startup ?
it might be easier to use nano rather than leafpad
sudo nano /etc/rc.local

(before exit 0 in the code) add the following:
sudo python3 /home/shutdown.py &

ctrl x y enter
reboot
Thankyou for the reply. It's what i made but didn't work.
Sorry for ny bad english and thank you for the help

Inviato dal mio ANE-LX2 utilizzando Tapatalk
try giving it permissions

sudo chmod 755 shutdown.py
oops..maybe.... sudo chmod 755 python3 shutdown.py
may need reboot
I try what you suggest, but, as you see in the photo below, the correct sintax is without python3 or python, but nothing happen.
In the second photo you see it in function, after pressing the button.
What can i try? [Image: 2339f03c8326de7f6ddf352935be65c4.jpg][Image: 7704b250ead3f49ccda3935f441f5810.jpg]

Inviato dal mio ANE-LX2 utilizzando Tapatalk
Done.

follow this step: https://bre.is/CVB_1qr2R

Exclamation Exclamation  Exclamation  Attention at step 5:
activate on sturt up
"In order to make the shutdown button 'active' when your Raspberry Pi starts up, you need to include it in an rc.local script.

Open a new terminal and type sudo nano /etc/rc.local

This will open the Leafpad editor, with the rc.local file loaded. At the end of the file (before exit 0 in the code) add the following:
sudo python3 /home/pi/shutdown.py &

Save the file and exit nano.

STEP 6
sudo chmod 755 shutdown.py

Reboot the system.

Big Grin

Thank you jim321 for the suggestions