RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    [HELP] GPIO signal during shutdown

    Scheduled Pinned Locked Moved Help and Support
    gpio shutoff
    2 Posts 1 Posters 361 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cyperghostC
      cyperghost
      last edited by cyperghost

      Hello fellows,

      According to the systemd helppage for system-halt we can initiate a script during shutoff sequence if we but a file to /lib/systemd/system-shutdown/ path. According to the halt signal we can choose between shutdowns, reboots .....

      I'm able to use the file with full GPIO support on a PI0/1 and a PI2 ... So the LED blinks 3 times during shutdown. I'm not able to run this on a PI3 with RetroPie 4.3 and the STRETCH images also. So there seems no initiation of a GPIO during shutdown here.

      So dear community I need your help. We need to connecte a LED to a working GPIO and to ground. then we need to create a small script and make it executable via chmod.

      1. type sudo nano /lib/systemd/system-shutdown/gpio-shutoff
      2. Insert code from box below!
      3. Make script executable with sudo chmod +x /lib/systemd/system-shutdown/gpio-shutoff
      4. Shutoff via commandline, ES menu or ....

      example shutoff script!

      #!/bin/sh	
      # Testscript for proper GPIO signal on shutdown
      	
      led_pin=17	
      		
          /bin/echo $led_pin > /sys/class/gpio/export	
          /bin/echo out > /sys/class/gpio/gpio$led_pin/direction	
      	
              for iteration in 1 2 3; do	
                  /bin/echo 0 > /sys/class/gpio/gpio$led_pin/value	
                  /bin/sleep 0.2	
                  /bin/echo 1 > /sys/class/gpio/gpio$led_pin/value	
                  /bin/sleep 0.2	
             done	
      
      /bin/sleep 5
      

      So this script let's blink a LED connected to GPIO17 and GROUND

      If you test can you please tell...
      Which Raspberry did you use?
      Which version of RetroPie or annother OS did you use?

      Thank you
      cyperghost

      PS: @herb_fargus @BuZz any ideas? Link to starting thread

      cyperghostC 1 Reply Last reply Reply Quote 0
      • cyperghostC
        cyperghost @cyperghost
        last edited by

        Tested: on Raspberry Pi 3 with RetroPie 4.3 and RetroPie 4.4 - works
        Tested: on Raspbian STRECH 4.9 kernel (March 2018) - works

        This is working flawless now!

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.