1

I am new to Raspberry Pi and am trying to use the headless shutdown module provided by Adafruit.

I downloaded the script of Adafruit-GPIO-Halt to my Raspberry Pi, installed it to the /usr/local/bin/gpio-halt file and even made a file on the system/system folder, following the steps on https://www.recantha.co.uk/blog/?p=13999.

However, the file in the systemd/system folder is getting saved with a .service.save extension and system prevents me from using the line sudo chmod 644 /lib/systemd/system/gpio-halt.service by saying, 'Permission denied.'

I would like to set-up the code to run on start-up. I am using Raspbian Version 9(stretch). Please help.

  • 1
    If you want help post a link to the module, and describe in detail what YOU did, not a link to an old tutorial for an obsolete OS. – Milliways Feb 18 '20 at 03:18
  • Hi @Atharv Goel, Welcome and nice to me you. Ah let me see, the headless Rpi shut down trick has many variations, yours is not that newbie friendly because you need to install the newbie scary Git thing, and compile a hard to understand C program. I would suggest you to try a more newbie friendly, no Git, no compile, just a short python script. / ton continue, ... – tlfong01 Feb 18 '20 at 05:04
  • 1
    Are you just trying to shutdown with a button? I thought you were referring to a power module NOT code. – Milliways Feb 18 '20 at 05:08
  • The secret Rpi shut down trick needs to short/connect two Rpi GPIO pins, using a manual switch, or just a paper clip. There is also a David Copperfield like magic variation using a tilt switch, then you don't even need a paper clip, just TURN KEYBOARD UPSIDE DOWN and Rpi will switch off by itself. The trick is here: (1) Simple Shutdown Raspberry Pi Button by Using GPIO: https://www.instructables.com/id/Simple-Shutdown-Raspberry-Pi-Button-by-Using-GPIO/ https://www.instructables.com/id/Simple-Shutdown-Raspberry-Pi-Button-by-Using-GPIO/. – tlfong01 Feb 18 '20 at 05:14
  • The tilt switch, a cheapie toy like thing is just a switch which shorts/connects two contact points when you tilt it. For more details, you can search this forum using the keyword "tilt switch". Now if you show your magic Rpi shut down to your bad friends or your daughter, then they would start to respect you more than you deserve. :) – tlfong01 Feb 18 '20 at 05:19
  • PS - I learnt this trick in Rpi One days, and I read about it from time to time in various forums. I guess this trick works in all OS versions of Rpi1/2/34. The other good thing is that although you don't need to know how the program woks, if you like to know a little more about python "low level system" programming, eg, (1) How to mess around with the program starting rc.local file, (2) python OS commands like "os.system('sudo shutdown -h now')", you can show off this "advanced" stuff to your bad friends, convincing them you are not just a friendly, blindly, copy, paste, run programs guy. – tlfong01 Feb 18 '20 at 05:42
  • 1
    Hello, for newer versions of Raspbian (like Stretch) the script/post you're linking to is no longer required as the same functionality is provided by the gpio-shutdown device tree overlay: https://raspberrypi.stackexchange.com/a/77918/93934 – Roger Jones Feb 18 '20 at 09:33
  • @Roger Jones, Many thanks pointing out my ignorance about headless shut down. I googled and skimmed the following posts and found them very good: Raspberry pi powerdown and powerup button https://www.stderr.nl/Blog/Hardware/RaspberryPi/PowerButton.html. The ninja guys talking there make me embarrassingly losing face. – tlfong01 Feb 20 '20 at 02:09
  • ERRATA AND APOLOGY - My earlier suggestion above using rc.local, python os command, GPIO monitoring daemon is TOTALLY RUBBISH. As advised by @Roger Jones, "gpio-shutdown" Device Tree overlay is the correct, trendy way to go: Reference: (1) "Raspberry Pi Power Down and Power Up Button": stderr.nl/Blog/Hardware/RaspberryPi/PowerButton.html. Sorry again and cheers. (PS to the OP: If you misleadingly follow me, the old dog's outdated rubbish suggestion, your bad friends should LOL and begin to respect you even less than you deserve) :) – tlfong01 Feb 20 '20 at 02:25

0 Answers0