Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Senior Member
    Join Date
    Jul 2020
    Posts
    248

    Using the RemotePi board with pCP

    The RemotePi boards offers a shutdown button and infrared for connecting a remote. The shutdown button is also operated by the remote so you can turn the Pi on either with the button or using the remote.

    To install on PcP requires some custom scripts top be installed. And please note that to install on top of a DAC you might need to change the pin for the remote. (this can be done on the board or or in the wiring when you connect the board - I did the latter using jumper wires).

    As a starting point for this guide I assume you have PCP running and know how to access it through SSH. I also recommend installing Nano as an editor (you can remove it again once everything works).

    Step 1: Installing Nano:
    - Go to piCorePLayer main page and click on "extensions"
    - If all checks are green, click on the "available" tab,
    - From available extensions, select "nano.tcz" and click "load"

    Step 1b: Add the following code to disable line wrap and autoindent, which is easier when copy/pasting code
    - Log in with SSH and type
    Code:
     nano .nanorc
    Code:
    unset autoindent
    set nowrap
    - Exit nano (ctrl-x) and save the file.

    Step 2: Add the IR power button to the RemotePi board
    - Press the on/off button on the RemotePi board for 10 seconds until you see the green light flashing.
    - Press the power key on the remote once to learn power on, and a second time to learn power off.
    (this step is also described as step 3 in the guide here)

    Step 3: create the Shutdown monitoring and shutdown script:
    - Log in with SSH and type
    Code:
     sudo nano /opt/shutdown.sh
    Code:
    #!/bin/sh
    
    #aplay /home/tc/sounds/goodbye.mp3 [optional: you can have a shutdown sound here]
    
    #send shutdown sequence to PiRemote powerboard
    echo "15" > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpio15/direction
    echo "1" > /sys/class/gpio/gpio15/value
    sleep 0.125
    echo "0" > /sys/class/gpio/gpio15/value
    sleep 0.2
    echo "1" > /sys/class/gpio/gpio15/value
    sleep 0.4
    echo "0" > /sys/class/gpio/gpio15/value
    echo "14" > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpio14/direction
    echo "1" > /sys/class/gpio/gpio14/value
    sleep 6
    - Exit nano (ctrl-x) and save the file.
    - Make the file executable: sudo chmod +x /opt/shutdown.sh

    Step 4: create the monitoring script:
    - Log in with SSH and type
    Code:
     sudo nano startup.sh
    Code:
    #!/bin/sh
    
    #things to do at startup
    pcp power off
    #start Irexec - optional: only if you use the ir remote with a custom lircrc file
    #/usr/local/bin/irexec /home/tc/.lircrc & (optional)
    
    #all set play a sound
    # aplay /home/tc/sounds/startup.mp3 (optional)
    sleep 2
    
    #turn on player at LMS
    pcp power on
    
    # this is the GPIO pin receiving the shut-down signal
    echo "14" > /sys/class/gpio/export
    echo "in" > /sys/class/gpio/gpio14/direction
    
    # going into a loop until shutdown
    while true; do
      sleep 1
      power=$(cat /sys/class/gpio/gpio14/value)
      if [ $power != 0 ]; then
      	pcp power off
    	sleep 2
        	echo "out" > /sys/class/gpio/gpio14/direction
        	echo "1" > /sys/class/gpio/gpio14/value
        	sleep 3
        	exitcheck.sh shutdown
      fi
    done
    Exit nano (ctrl-x) and save the file.
    - Make the file executable: sudo chmod +x startup.sh

    At this point you're done installing scripts. Since you're not doing this in the pCP web interface you will need to backup your changes manually.
    - Log in with SSH and type
    Code:
    PCP BU
    Step 5: Install lirc and upload a .lircd file
    - Go to the pCP web interface and click on the tweaks tab.
    - Go to the IR page and install Lirc.
    - Under device settings, choose GPIO: 18, and irdevice lirc0
    (note: if you changed it in the wiring, this is GPIO 17)

    You probably also need to upload a lirc.conf file. It depends on your remote what you need to upload here. If you bought a remote together with your RemotePi board, the contents of the Lirc.conf file can be found here. (Please note though that in every configuration file you should remove the line that defines the power key, since this is processed at the RemotePi board, so pCP doesn't have to do anything with this.)

    In principle pCP has enabled a default remote key mapping for most functions on Squeezelite (pause/play/volume,etc..) so that should work out of the box, but if you want to use additional keys you also need to upload a '.lircrc' file. (I did this to use the number keys for presets.)

    Step 6: Run the startup script that monitors the RemotePi button:
    - Go to the pCP web interface and click on the tweaks tab.
    - Scroll down and under User Commands enter:
    Code:
    /home/tc/startup.sh
    This will make the startup script, which monitors the power button, run by default when you start pCP. You can later check the logfiles under diagnostics to see if it does.

    Step 7: Shutdown and restart
    You're now all set.
    - Go to the main page and choose "backup" and "shutdown" to turn off your Pi .
    - Unplug the power and plug it back in

    When you plug back in the RemotePi switch lights up red. You can now use the remote to turn on the Pi.
    During startup the green LED will flash for 75 seconds. During this time your Pi is starting up, with pCP it usually takes about 30 seconds, but the green light will continue flashing regardless.

    When you shutdown the Pi using the remote or the button on the RemotePi, the red light will flash until the Pi has fully shutdown and then switch off the power. If it doesn't shutdown properly the RemotePi will continue flashing red for 4 minutes before doing a hard shutdown.

    If all works well though the red LED will flash for about 30 seconds until your Pi is shut down.The RemotePi board then cuts the power and the red light in the power button turns on.

    Step 8 [bonus]: Reduce the power on time and the LED brightness
    - You can use the instructions on the RemotePi website to reduce the green blinking time at startup (I set mine to 25 seconds, which is more than enough) and reduce the brightness of the power button and the LED.
    Last edited by jeroen2; 2021-01-16 at 17:13.

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    248
    Moved and updated here: https://docs.picoreplayer.org/projects/setup-remotepi/
    Attached Files Attached Files
    Last edited by jeroen2; 2021-01-26 at 09:40. Reason: updates

  3. #3
    Senior Member Greg Erskine's Avatar
    Join Date
    Sep 2006
    Location
    Sydney, Australia
    Posts
    2,176
    Great!

    Would you like me to add these instructions to the piCoreplayer Documentation under "Projects"?

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    248
    Quote Originally Posted by Greg Erskine View Post
    Would you like me to add these instructions to the piCoreplayer Documentation under "Projects"?
    Thanks! I posted this because someone asked for it here. If you feel the above is complete, please feel free to post on the Documentation site as well.

  5. #5
    Senior Member Greg Erskine's Avatar
    Join Date
    Sep 2006
    Location
    Sydney, Australia
    Posts
    2,176
    Thanks jeroen2,

    I have added "Setting up the RemotePi" to the Projects section.

  6. #6
    Junior Member
    Join Date
    Jan 2021
    Posts
    5
    Quote Originally Posted by jeroen2 View Post
    Thanks! I posted this because someone asked for it here. If you feel the above is complete, please feel free to post on the Documentation site as well.
    jeroen: many thanks for this great work, did not expect so detailed instructions. Really helpfull for people like me with limited Linux and scripting skills. Will report my progress with the remotepi board when arrived here.

    best regards

    bla

  7. #7
    Senior Member
    Join Date
    Jan 2006
    Location
    Boston
    Posts
    261
    Thank you jeroen2, looking forward to setting up my RemotePi which seems to be stuck at USPS ISC (Intl Service Center) in NYC, two weeks already..

  8. #8
    Senior Member
    Join Date
    Jul 2020
    Posts
    248
    Quote Originally Posted by Greg Erskine View Post
    Thanks jeroen2,

    I have added "Setting up the RemotePi" to the Projects section.
    Great, thanks Greg!

    Just noticed one mistake (which is indeed wrong in the attached txt document, but correct in the posting above). Under step 5, the default GPIO for the IR receiver should be 18, but can be changed to 17 if needed. (if you have a HifiBerry board it needs to be changed to 17).

  9. #9
    Senior Member Greg Erskine's Avatar
    Join Date
    Sep 2006
    Location
    Sydney, Australia
    Posts
    2,176
    Thanks.

  10. #10
    Junior Member
    Join Date
    Jan 2021
    Posts
    5
    Hi,

    2 days ago, my RemotPi board (for Raspi 4B with external IR and LED) arrived from Thailand (I'm living in Germany) without any additional costs to pay for VAT or tariffs.
    I installed the board according the instructions from above and everything was working as expected immediatly. I could switch on the Raspi via button or IR remote (had to teach the RemotePi a button from my remote during installation as instructed)
    Shutdown via button or IR remote was also working on first try after installing the scripts as described above. What I have not tested so far is LIRC and additional remote functions but this will come later.

    Some remarks for the installation instructions:
    at Step 3: I was suprised that there is already a file "shutdown.sh" with content in my installation, I have inserted the code lines from Step 3 directly under "user shutdown commands"
    at Step 4: would be good to note the path where this file has to be stored (I have used /home/tc)
    Code: PCP BU is for me only working with small letters (pcp bu)

    Many thanks to jeroen and all the other contributors for making the installation of a RemotePi board a charm

    best regards

    bla

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •