This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shutdown button with moitessier hat
#1
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
Reply
#2
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?
Reply
#3
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
Reply
#4
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
Reply
#5
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
Reply
#6
try giving it permissions

sudo chmod 755 shutdown.py
oops..maybe.... sudo chmod 755 python3 shutdown.py
may need reboot
Reply
#7
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
Reply
#8
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)