• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login

Multi Switch Shutdown Script!

Scheduled Pinned Locked Moved Ideas and Development
shutdown scriptshutdown switchcyperghost
272 Posts 40 Posters 109.4k 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.
  • C
    cyperghost @gollumer
    last edited by cyperghost 5 Jan 2018, 18:55 1 May 2018, 17:53

    @gollumer said in Multi Switch Shutdown Script!:

    Lol. Yeah, I originally had the fan connected to the fan connector, but recently changed it due to the noise. You're right: the fan doesn't shut down. I'm not at home right now, but when I get home I'll try the command you suggest (raspi-gpio set 4 op dl) from the terminal and see what happens.

    Yes, thank you. I think that's the way the GPIO is intended for.

    @cloudlink
    About GPIO17, of course both of you can shutoff the fan by uncommenting line 184 in my script and then edit the call in line 311

     NESPiPlus 2 3 4 14
    
    to
    
     NESPiPlus 2 3 17 14
    

    But I assume GPIO 4 shutoff the fan if installed in case connector!

    1 Reply Last reply Reply Quote 0
    • G
      gollumer
      last edited by 1 May 2018, 18:25

      Ok, I tried aspi-gpio set 4 op dl from the terminal, and nothing happened (as expected).

      I then uncommented line 184, and edited line 311 as shown (replaced 4 with 17). I rebooted, then shutdown using the button. Shutdown is fine, but the fan is still working. So...perhaps I do need to go back to using fan connector.

      C 1 Reply Last reply 1 May 2018, 19:01 Reply Quote 0
      • C
        cyperghost @gollumer
        last edited by cyperghost 5 Jan 2018, 20:18 1 May 2018, 19:01

        @gollumer Yes I think the fan connector works with GPIO4, so please uncomment the line 184 and set the number back to 4. I think then it's possible to shutoff the fan.

        Do you really use GPIO 17 or do you mean PIN 17 (That's a 3.3V Pin) and can't be shutoff! So this does not work at all! I would assume to the old connection provided by the case itself ;) GPIO 4 and the connector on the NESPi+ board ;)

        G 1 Reply Last reply 1 May 2018, 20:20 Reply Quote 0
        • C
          cloudlink
          last edited by 1 May 2018, 19:46

          Thank you cyperghost.
          I connected my fan to the Nespi+ fan pins. I uncommented line 184 in /home/pi/RetroPie/scripts/multi_switch.sh. Now my fan turns on when I power on the system and my fan turns off when I power off the system.
          I have the issue though where my fan is way too loud, spinning way too fast. Is it possible to control the power level?

          C 1 Reply Last reply 1 May 2018, 21:13 Reply Quote 1
          • G
            gollumer @cyperghost
            last edited by gollumer 5 Jan 2018, 21:26 1 May 2018, 20:20

            @cyperghost said in Multi Switch Shutdown Script!:

            @gollumer Yes I think the fan connector works with GPIO4, so please uncomment the line 184 and set the number back to 4. I think then it's possible to shutoff the fan.

            Do you really use GPIO 17 or do you mean PIN 17 (That's a 3.3V Pin) and can't be shutoff! So this does not work at all! I would assume to the old connection provided by the case itself ;) GPIO 4 and the connector on the NESPi+ board ;)

            EDIT: Ok, I see...pin 17 on the GPIO board isn't the same as GPIO 17. I'm connected to pin 17.

            https://pinout.xyz/

            1 Reply Last reply Reply Quote 0
            • C
              cyperghost @cloudlink
              last edited by cyperghost 5 Jan 2018, 22:47 1 May 2018, 21:13

              @cloudlink Okay NESPi+ is 100% supported now, thank you.
              About the spinning speed.... Well I would not use resistors because you will likely need some that resists to 1-2Watts. The easiest way imho is to use 1 or 2 simple Si diodes. Each drops the voltage up to 0.7V so you have 4.3V if you use one or 3.6V if you use two diodes. That's a dirty hack but will work - 1N4001 and higher are a good choice.
              The cleanest (cheap) way would be a step down regulator. The masters/professional way is a PWM regulator together with NTC/PTC ;)

              @gollumer Yes we talk about BCM numbers and physical PINs there are also wPi numbers for complete confusion! But you're right use the common pinout helpers that are free to use ;)

              1 Reply Last reply Reply Quote 0
              • G
                gollumer
                last edited by 1 May 2018, 21:48

                Ok, I connected the fan back to the FAN connectors, and edited line 311 back to NESPiPlus 2 3 4 14. I tried it first with line 184 still un-commented. It wouldn't shut down, but would instead go into a reboot loop. (Shut down, immediately reboot, part-way through ES loading up, it would shut down again, then reboot...and keep doing that.) I then edited line 184 and commented it out again. It now shuts down, but the fan does not turn off. Only way to turn off the fan is to unplug the power supply.

                C 1 Reply Last reply 1 May 2018, 21:59 Reply Quote 0
                • C
                  cyperghost @gollumer
                  last edited by 1 May 2018, 21:59

                  @gollumer You can update script

                  1. cd /home/pi/RetroPie/scripts
                  2. rm multi_shutdown.sh
                  3. wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh

                  I updated to 0.42

                  G 1 Reply Last reply 1 May 2018, 22:16 Reply Quote 0
                  • G
                    gollumer @cyperghost
                    last edited by 1 May 2018, 22:16

                    @cyperghost said in Multi Switch Shutdown Script!:

                    @gollumer You can update script

                    1. cd /home/pi/RetroPie/scripts
                    2. rm multi_shutdown.sh
                    3. wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh

                    I updated to 0.42

                    Ok, I updated the script. Unfortunately, it now gets stuck in the reboot loop when shutting down. It gets several seconds into the video splash screen, then reboots...keeps doing that over and over until I unplug.

                    C 1 Reply Last reply 2 May 2018, 03:37 Reply Quote 0
                    • C
                      cyperghost @gollumer
                      last edited by cyperghost 5 Feb 2018, 04:59 2 May 2018, 03:37

                      @gollumer That's weird becasue @cloudlink reports good results.
                      Then please comment line 183, then the same version is restored.

                      This is caused as you leave the LOOP caused by a button press. But don't know why ... can you recheck the ON/OFF position of the switch. Can you shot some photos from you setup?

                      Then later you can use the raspi-gpio command raspi-gpio set 4 op dl manuell then you immedialty should loose power. And more weird becasue you said you typed the command raspi-gpio command later and nothing happens... But again: weird becasue cloudlink got good results. I can help you to shut off then fan with a workaround but let us eloborate this first.

                      1 Reply Last reply Reply Quote 0
                      • C
                        cloudlink
                        last edited by 2 May 2018, 04:51

                        Mine is working perfectly.
                        If I have an emulator running and I hit Reset, it only exits the emulator. If I have no emulator running and I hit Reset, it restarts Emulationstation.
                        If it is off and I press the Power button, it powers on. If it is on and I press the Power button, it safely saves metadata and shuts down.

                        I have noticed though that if I press and release the Reset button too quickly, it does not work. Is there a configured amount of time it must be held?

                        1 Reply Last reply Reply Quote 0
                        • G
                          gollumer
                          last edited by gollumer 5 Feb 2018, 06:22 2 May 2018, 05:21

                          Ok, I've commented line 183. It now shuts down properly again, but the fan still runs.

                          I turned it back on, exited ES, then typed the raspi-gpio set 4 op dl command. Nothing happened. The fan keeps running.

                          I've re-checked the on-off switch. It's firmly all the way in the on position.

                          Here's a photo, if that helps. (For some reason the photo isn't showing up...) Here's the direct link instead: https://www.dropbox.com/s/vgt95faj8oe65ib/raspi3.jpg?dl=0
                          photo

                          C 1 Reply Last reply 2 May 2018, 19:18 Reply Quote 0
                          • C
                            cyperghost @gollumer
                            last edited by cyperghost 5 Feb 2018, 20:50 2 May 2018, 19:18

                            @gollumer The link you've posted is not working :( So it may be helpfull to upload your photo again ;)

                            I assume two things as @cloudlink is reporting a good shot and even a powered down fan.

                            1. There are several cases around with different PCBs (maybe annother reversion)
                            2. You have annother script running in background

                            You are talking about an endless reboot loop...
                            This isn't possible with my script. In the worst case it will powerdown the Raspberry, but won't reboot. Can you post output of ps -la please? This will show all programms running. So you can be sure no other script is running.

                            Sadly I don't have this case! Without this it's a bit difficult to give you best advices. So it's just a bit of try and error! But I've to thank your for your energy in testing.

                            Can you type raspi-gpio set 4 op dl if ES is running? And what is happening then?

                            @cloudlink

                            I have noticed though that if I press and release the Reset button too quickly, it does not work. Is there a configured amount of time it must be held?

                            Yes it's the sleep loop. The state of all switches is polled only every second. So it can take up to one second until the button press is detected. It's caused by the script itself you may use sleep 0.5 instead of sleep 1

                            1 Reply Last reply Reply Quote 0
                            • G
                              gollumer
                              last edited by 2 May 2018, 20:12

                              Thank you very much for your help, you've been very patient.

                              I re-sized the image after I posted the link, so I think Dropbox thought it was a new image. Here's a new link: https://www.dropbox.com/s/cevy9c5zeijm434/raspi3.jpg?dl=0

                              Here's the output from ps -la:

                              pi@retropie:~ $ ps -la
                              F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
                              4 S  1000   914   631  0  80   0 -  1272 wait   tty1     00:00:00 bash
                              0 S  1000   919   914  0  80   0 -  1152 wait   tty1     00:00:00 bash
                              0 S  1000   920   919  0  80   0 -  1192 wait   tty1     00:00:00 multi_switch.sh
                              0 S  1000   921   919  0  80   0 -  1154 wait   tty1     00:00:00 emulationstatio
                              0 S  1000   931   921  0  80   0 -   477 wait   tty1     00:00:00 emulationstatio
                              0 S  1000   934   931 43  80   0 - 49770 futex_ tty1     00:00:43 emulationstatio
                              0 S  1000  1833   920  0  80   0 -   849 hrtime tty1     00:00:00 sleep
                              0 R  1000  1835  1676  0  80   0 -  1070 -      pts/0    00:00:00 ps
                              pi@retropie:~ $
                              

                              When I run this command (raspi-gpio set 4 op dl) with ES running, nothing happens. I get straight back to the command prompt (running in an SSH session from my laptop). Fan still runs.

                              I hope this helps.

                              C 1 Reply Last reply 2 May 2018, 20:30 Reply Quote 0
                              • C
                                cloudlink
                                last edited by 2 May 2018, 20:28

                                I'm not sure if this could cause the issue, but I had to correct the path in step 5 of the installation instructions at the top of this thread:
                                From
                                /home/pi/RetroPie/multi_switch.sh --nespi+ &
                                To
                                /home/pi/RetroPie/scripts/multi_switch.sh --nespi+ &

                                1 Reply Last reply Reply Quote 1
                                • C
                                  cyperghost @gollumer
                                  last edited by cyperghost 5 Feb 2018, 21:34 2 May 2018, 20:30

                                  @gollumer Thanks.... Yes it looks all clean.
                                  Annother user posted an image of the case maybe you can compare revision numbers but I see really no error in the setup.... strange strange strange....

                                  https://retropie.org.uk/forum/assets/uploads/files/1524513129693-ea70831d-e612-440b-ac18-af8fb3ac75a3.jpeg

                                  Can you please post output of cat /opt/retropie/configs/all/autostart.sh

                                  @cloudlink Oh really? Yes that a wrong path! Indeed. I corrected this! Thank you so much. That may caused the issue at all! And your fan shuts off if you powerdown the system?

                                  G 1 Reply Last reply 2 May 2018, 20:54 Reply Quote 0
                                  • C
                                    cloudlink
                                    last edited by 2 May 2018, 20:34

                                    Sorry I didn't think to mention that earlier. I forgot I had corrected that, but I just remembered while retracing my steps.
                                    See if that fixes the issue.

                                    1 Reply Last reply Reply Quote 1
                                    • C
                                      cloudlink
                                      last edited by 2 May 2018, 20:37

                                      Yes, my fan shuts off when the system shuts down after I uncommented line 184 in /home/pi/RetroPie/scripts/multi_switch.sh

                                      1 Reply Last reply Reply Quote 1
                                      • G
                                        gollumer @cyperghost
                                        last edited by 2 May 2018, 20:54

                                        @cyperghost said in Multi Switch Shutdown Script!:

                                        Can you please post output of cat /opt/retropie/configs/all/autostart.sh

                                        Here you go:

                                        pi@retropie:~ $ cat /opt/retropie/configs/all/autostart.sh
                                        /home/pi/RetroPie/scripts/multi_switch.sh --nespi+ &
                                        emulationstation #auto
                                        C 1 Reply Last reply 2 May 2018, 20:56 Reply Quote 1
                                        • C
                                          cyperghost @gollumer
                                          last edited by cyperghost 5 Feb 2018, 21:56 2 May 2018, 20:56

                                          @gollumer and now... output of ls /home/pi/RetroPie/scripts

                                          I still found no error ;)

                                          G 1 Reply Last reply 3 May 2018, 03:40 Reply Quote 0
                                          51 out of 272
                                          • First post
                                            51/272
                                            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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received