Announcement

Collapse
No announcement yet.

piCorePlayer and On / Off software switch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    piCorePlayer and On / Off software switch

    Hello,

    I'm looking t implement a software safe-shutdown switch to my Picoreplayer.
    I tried to follow this process and install that script below to no avail as there are missing dependencies.
    This guide will show you how to add a power button or switch to your Raspberry Pi that can turn your Pi on or off.


    Is there a way to use something similar?

    As my streamer is going to draw power from the dock of an old B&W Zeppelin, it's quite important for me to be able to shutdown the Pi and not let it run of off the dock 24/7.

    Many thanks

    #2
    This Raspbian based solutions assume you have python installed.

    piCorePlayer doesn't have python or the required python modules loaded. Python is actually bigger than the whole of piCorePlayer.

    piCorePlayer does have microPython loaded, but I don't know if the required microPython module is available.

    On the Tweaks page there is Poweroff/Shutdown Overlays section that may help.

    I haven't played with this for many years, so hopefully someone who has done it recently will help out.

    Another point is wiringPi is depreciated, some solutions are based on it, use pigpio instead.

    BTW: If you are using piCorePlayer just as a player (no LMS) you can simply turn it off or pull the plug.

    Comment


      #3
      Hi,
      Can this thread help?
      https://forums.slimdevices.com/showt...overlays/page3
      It shows how to configure the shutdown options in PiCorePlayer configuration.
      The link you provided includes a Python script. I am not sure if Python is installed by default in PcP... not even sure why they use Python in that script? Anyway I would use PcP capabilities, making sure the GPIO pins are well identified.

      EDIT: sorry Greg's post appeared at the same time as mine.

      Comment


        #4
        Originally posted by Greg Erskine View Post
        This Raspbian based solutions assume you have python installed.

        piCorePlayer doesn't have python or the required python modules loaded. Python is actually bigger than the whole of piCorePlayer.

        piCorePlayer does have microPython loaded, but I don't know if the required microPython module is available.

        On the Tweaks page there is Poweroff/Shutdown Overlays section that may help.

        I haven't played with this for many years, so hopefully someone who has done it recently will help out.

        Another point is wiringPi is depreciated, some solutions are based on it, use pigpio instead.

        BTW: If you are using piCorePlayer just as a player (no LMS) you can simply turn it off or pull the plug.
        Hi Greg.
        Thank you so much with this.
        I was just taking a look at the Poweroff/Shutdown Overlays. I hope someone will be able to guide me through this.
        I want to run a simple shutdown script.
        Pulling the plug is not easy in my setup as the Pi is mounted on the dock and the plug is somehow covered by the case itself.

        Comment


          #5
          Originally posted by truscellino View Post
          Hi,
          Can this thread help?
          https://forums.slimdevices.com/showt...overlays/page3
          It shows how to configure the shutdown options in PiCorePlayer configuration.
          The link you provided includes a Python script. I am not sure if Python is installed by default in PcP... not even sure why they use Python in that script? Anyway I would use PcP capabilities, making sure the GPIO pins are well identified.

          EDIT: sorry Greg's post appeared at the same time as mine.
          Thank you so much for this! I'd rather not mess with Python if what I want to achieve is doable with the PcP.
          Just to clarify, should I wire up the momentary button on GPIO 22 and 17? Will it wake up the device aside from powering it down?

          Comment


            #6
            We use this method. Look at the gpio-shutdown and gpio-powerdown.



            Then look at the tweaks page, thats where these get enabled. If you would rather not use the overlay method, there is a script at /home/tc/pcp-powerbutton.sh which you can edit/tweak/configure.....then put that script in the user command box on the tweaks page.
            piCorePlayer a small player for the Raspberry Pi in RAM.
            Homepage: https://www.picoreplayer.org

            Please donate if you like the piCorePlayer

            Comment


              #7
              Originally posted by gtj View Post
              Thank you so much for this! I'd rather not mess with Python if what I want to achieve is doable with the PcP.
              Just to clarify, should I wire up the momentary button on GPIO 22 and 17? Will it wake up the device aside from powering it down?
              Hi,
              In the thread I referred to, the GPIO pins in my case were imposed by the board I was using (which is a DAC with included power switch capabilities), so in PcP "tweaks" I had to set the GPIO pins with respect to hardware configuration. Previous posts in the same thread mention different GPIO pins. It depends on your wiring...
              for your on/off switch, you have to chose pins:
              • that are configurable (i.e. not a fixed ground or 5V pin!)
              • that are not used by another function e.g. for sound

              See pinout: https://www.raspberrypi.org/documentation/usage/gpio/
              GPIO 17 and 22 are OK but they are not the only ones... I think the PcP on/off functions work very well, you should get it to work quickly.

              Edit: not sure about waking up from sleep... not even sure PcP enables sleep of the Pi?? I have never looked into this.
              Last edited by truscellino; 2020-05-07, 13:48.

              Comment


                #8
                Originally posted by truscellino View Post
                Hi,
                In the thread I referred to, the GPIO pins in my case were imposed by the board I was using (which is a DAC with included power switch capabilities), so in PcP "tweaks" I had to set the GPIO pins with respect to hardware configuration. Previous posts in the same threads mention different GPIO pins. It depends on your wiring...
                for your on/off switch, you have to chose pins:
                • that are configurable (i.e. not a fixed ground or 5V pin!)
                • that are not used by another function e.g. for sound

                See pinout: https://www.raspberrypi.org/documentation/usage/gpio/
                GPIO 17 and 22 are OK but they are not the only ones... I think the PcP on/off functions work very well, you should get it to work quickly.
                Thanks for your help. Much appreciated.
                However that's not fooll-proof enough for my basic knowledge and understanding so to avoid sorting anything and damaging my equipment altogether.
                I have no idea how the gpio pins work (active low high etc). I'm only used to run preconfigured scripts for the job I need. Therefore I'm forced to look elsewhere.

                Comment


                  #9
                  From the photos below is it safe to assume that I have to wire the button to pins 9 & 11 (GPIO17) ?
                  Attached Files

                  Comment


                    #10
                    Hi,
                    Yes exactly, if you want GPIO 17 then it's pin 11 + one pin with GND.
                    In the tutorial you mentioned early in this thread, they used pins 5-6 because of choice of GPIO 3, hence the Python code provided:
                    Code:
                    GPIO.setmode(GPIO.BCM)
                    GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
                    GPIO.wait_for_edge(3, GPIO.FALLING)
                    
                    subprocess.call(['shutdown', '-h', 'now'], shell=False)
                    The script included in PiCorePlayer replaces that Python and in the "Tweaks" you can select the type of button (active low or high) and the GPIO pin. I can't see much risk in trying, worst case it won't work... please let us know how it goes

                    Comment


                      #11
                      Hi,
                      I just had another look at the documentation plink provided by Paul.
                      https://github.com/raspberrypi/linux...ys/README#L877
                      From what I understand (I might be wrong...):
                      1. if you use GPIO 17 then it should work fine for a shutdown but then I suspect it won't work to power up.
                      2. The Pi can be powered up using a button on GPIO 3 (pin 5), hence the choice made in the tutorial you referred to. BUT, from the other forum thread, I understand that you need to disable I2C in PcP to allow for the button to be listened to on that pin... see link below to the post. You need to make the choice...


                      https://forums.slimdevices.com/showt...l=1#post940096

                      Comment

                      Working...
                      X