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
- 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
- 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
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
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:
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.
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
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
- 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
- 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
- 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
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.