Install guide Audiophonics I-Sabre V3/RaspDAC Power button

I figured it’d be nice to have a guide to get the non latching power button for the Audiophonics I-Sabre V3 working with a DietPi image! Feel free to suggest additions/changes. These are a laymans work and probably can be bettered!
The source code have been put together from various pages and repositories, mostly from Audiophonics french forums…

Install DietPi
Download the latest DietPi image for Raspberry Pi (http://dietpi.com/)
Install the image onto your MicroSD using Apple Pi Baker or Win32 Disk Imager or whatever you like.
Insert the MicroSD into your Audiophonics RaspDAC (or similar with a non latching button)
Apply power and push the button to initiate bootup
Give the Pi a couple of minutes to resize storage and perform necessary duties.
Login using SSH:

ssh root@<Raspberry IP Adress> (Password: dietpi)

Upon first login there will be some updating, be patient, grab a beer or other beverage of choice.
When it’s ready it will reboot. Give it another minute, then login once more

General configuration & software packages
The Diet-Pi Software meny will be shown.
Select Diet-Pi Config - Audio Options
Chose Soundcard and then select ”hifiberry-dac” from the list of options
When the necessary config is complete you will be returned to the meny.
I like to do the PSU Noise reduction choice also, your mileage may vary.

When done, go back to the DietPi-Software menu and chose Software Optimized
Scroll down to option 121 - Roon Bridge and select it. Exit and then use the Install option
This will take a few minutes, refill your drinks ladies and gents…
After reboot, login once more

Let get started with the Audiophonics requisites
Okay, lets get the necessary software aboard:

apt-get install rpi.gpio
apt-get install wiringpi

After the install, check to see that the GPIO API is available:

gpio readall

You should see a table showing the different GPIO connectors status.

Now, lets create the monitoring script that will kill the blink and allow you to press the button to shutdown:

nano pwrmgmt.sh

Paste this:

#!/bin/bash
#Volumio version

PATH=/usr/bin:/home/dietpi

echo "Audiophonics Power Management script starting..."
echo "Asserting pins : "
echo "ShutDown : GPIO17=in, Low"
echo "BootOK : GPIO22=out, High"
echo "SoftSD : GPIO04=out, Low"

gpio -g mode 04 out
gpio -g write 04 0
gpio -g mode 17 in
gpio -g write 17 0
gpio -g mode 22 out
gpio -g write 22 1

while [ 1 ]; do
if [ "$(gpio -g read 17)" = "1" ]; then
echo "ShutDown order received, RaspBerry pi will now enter in standby mode..."
/home/dietpi/softstop.sh &
break
fi
/bin/sleep 0.5
done

exit 0

Save the script and make it executable:

chmod +x pwrmgmt.sh

Move the executable script to a known location:

mv pwrmgmt.sh /home/dietpi/pwrmgmt.sh

Now we need to create another script, called softstop.sh:

nano softstop.sh

Add this code:

#!/bin/bash
# Audiophonics
# Shutdown detection script
# Script to set GPIO 4 High for 1sec
PATH=/usr/bin:/home/dietpi
echo "Setting pin GPIO4 High"
gpio mode 7 out
gpio write 7 1
/bin/sleep 1
echo "Setting pin GPIO4 Low"
gpio write 7 0
echo "RaspberryPi shutdown"
sudo shutdown -h -P now
exit 0

Save and exit
Make the script executable and move it to the same location as the other script:

chmod +x softstop.sh
mv softstop.sh /home/dietpi/softstop.sh

Now we will add the main script to the startup sequence:

nano /etc/rc.local

Add this line before the line that reads ”exit 0”:

/home/dietpi/pwrmgmt.sh &

Save and exit.

Reboot the RaspDAC by issuing a normal "reboot" command

In a few moments the RaspDAC will reboot and the blinkin’ LED will come to a stable state! Your RaspDAC will be available in Roon at this time if everything has gone OK.
Now push the power button briefly. The LED should start blinking and an in few seconds the RaspDAC will shutdown and the LED should go out.

All done!

3 Likes

@Mikael_Ollars

Excellent guide, many thanks for sharing :thumbsup:

Thanks Dan!

There’s just one small gripe with this. And that is the fact that this script is a stupid do-while-loop…
I cant see any other way to monitor the power switch either?
My Pi2b spends about 0.5-0.9% CPU on this script while playing redbook FLACs with Roon.

Any ideas to better this behaviour?

Oh, and i know DietPi is basically immune to being relieved of power while running but of course it feels better to perform a shutdown!
So the question remains, can you live with a blinking powerlight? :slight_smile:

You’ve already got the sleep in there, bash is a little process hog, even on basic scripts.
Cant really increase the sleep, unless gpio read can be read as “has been triggered in the past”, instead of “triggering now”.

1% of 1x 600MHz (assuming not at full load), thats fine :wink:

I’am immune to flashing lights now, thanks to DietPi over the years lol.

Thank you for posting this guide. I will try it tonight. Till now I haven’t been able to get the Audiophonics I-Sabre VS working with Roon. My Roon Server isn’t finding the Sabre V3 on the network, so it’s not selectable as audio output device. I’ve tried the Hifiberry Roon image 1.3 (but couldn’t figure out how to change the soundcard to the Audiophonics) and the latest Dietpi and installing the Roon bridge from the software selection menu. I noticed that you selected Hifiberry DAC as the soundcard and not the Audiophonics soundcard from the list. Maybe this was my mistake. I will try tonight. I’m using the DIY kit, i.e. I bought all of the components separately, RPi, Sabre V3 DAC board, case, power button, etc. I though it was going to be as easy as building a custom gaming PC, but it’s a little more challenging than I expected.

I use this power button here as well with my digione board. I just had to modify the script to use other GPIO pins as not all were available due to the DigiOne. The script is launched with a systemd service file.

OK, now it works. I selected hifiberry-dac as the soundcard and now Roon lists snd_rpi_hifiberry_dac as a networked audio device. Beneath that, it says “ALSA”. Will now try the script for the shutdown button.

1 Like

Excellent! It’s a very nice sounding little unit! You are aware that the Audiophonics SABRE DAC powers the Pi, not the other way around? And that it needs 7-9V for throttling this down to the necessary 3,3V and 5V?

Good luck! :smiley:

Yep, I picked up the 7V linear power supply from Audiphonics, so powering it with that. Sounds really nice so far. Are there any other settings that you recommend, e.g. volume settings on the dietpi or in Roon? Thanks.

Alright! :slight_smile: I don’t use volume control on the RaspDAC, as it feeds my Shiit Jotun line level. Actually listening right now!
I usually like to use a low power scheme for my Pi’s, but cannot say i can hear an obvious difference. It does keep temperature down though. (And i prefer Pi 2’s for their lack of WLAN and Bluetooth, sensible or not)

Hurraahhh, the power button script works like a charm. No more blinking. Thank you, Mikael!

1 Like

Does anyone know if I can also set up Audiophonics I-Sabre V3 as an Airplay device? Ideally, the device would show up in Roon as a networked audio device but also as an Airplay device, e.g. when I want to play something via WiFi from my iPad.

EDIT: I found it. Installed Shairport Sync and now I have both Roon Endpoint and Airplay device.

Hi,
I got my RaspDAC today and installed DietPi. I followed these instructions, created the shell scripts and added the line to /etc/rc.local file. I rebooted but unfortunately the power button is still blinking. The shutdown function is also not working.

If I start the pwrmgmt.sh script from the command line I get this:

root@DietPi:/home/dietpi# ./pwrmgmt.sh
Audiophonics Power Management script starting...
Asserting pins :
ShutDown : GPIO17=in, Low
BootOK : GPIO22=out, High
SoftSD : GPIO04=out, Low
./pwrmgmt.sh: line 12: gpio: command not found
./pwrmgmt.sh: line 13: gpio: command not found
./pwrmgmt.sh: line 14: gpio: command not found
./pwrmgmt.sh: line 15: gpio: command not found
./pwrmgmt.sh: line 16: gpio: command not found
./pwrmgmt.sh: line 17: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
./pwrmgmt.sh: line 20: gpio: command not found
^C

I then tried to enter the commands of the script on the command line

root@DietPi:/home/dietpi# gpio -g mode 04 out
root@DietPi:/home/dietpi# gpio -g write 04 0
root@DietPi:/home/dietpi# gpio -g mode 17 in
root@DietPi:/home/dietpi# gpio -g write 17 0
root@DietPi:/home/dietpi# gpio -g mode 22 out
root@DietPi:/home/dietpi# gpio -g write 22 1

and… the button stopped blinking… so the commands are ok but eventually I have made some mistake creating the scripts or even when setting up the system.

I’m new to DietPi and RaspberryPi… any help on this would be highly appreciated.

hi @papa.jay,
did you install wiringpi as written above with the apt-get command?

Is it working if you run the gpio command with its asolute path?
it should look like this:

dietpi@DietPi:~$ /usr/bin/gpio
Usage: gpio -v
       gpio -h
       gpio [-g|-1] ...
       gpio [-d] ...
       [-x extension:params] [[ -x ...]] ...
       gpio [-p] <read/write/wb> ...
       gpio <read/write/aread/awritewb/pwm/clock/mode> ...
       gpio <toggle/blink> <pin>
       gpio readall/reset
       gpio unexportall/exports
       gpio export/edge/unexport ...
       gpio wfi <pin> <mode>
       gpio drive <group> <value>
       gpio pwm-bal/pwm-ms
       gpio pwmr <range>
       gpio pwmc <divider>
       gpio load spi/i2c
       gpio unload spi/i2c
       gpio i2cd/i2cdetect
       gpio rbx/rbd
       gpio wb <value>
       gpio usbp high/low
       gpio gbr <channel>
       gpio gbw <channel> <value>
dietpi@DietPi:~$

You can try to run these commands again:
sudo apt-get update
sudo apt-get install rpi.gpio wiringpi

EDIT: I updated this reply, as I was posting for a different distribution in the first place. Now it refers to DietPi.

@Mikael_Ollars: I noticed there is a small typo in your post:

wiringPi in the line

apt-get install wiringPi

needs to be lowercase
(and apt-get requires sudo).

1 Like

hi christopher,

thanks for your comments.

no. i used the dietpi-software tool to install both packages because I wasn’t able to install the wiringPi package (probably related to the typo you pointed out later in your post)

grafik

no it didn’t but I found the gpio program in the /usr/local/bin directory and changed the path in both the pwrmgmt.sh and softstop.sh scripts. I rebooted the machine and the power button led stopped blinking. hooray :slight_smile:

Thanks for the hint.

Anyway I think there is something wrong with the “shutdown” as well.

The abot mention part is not working for me.

If I type the shutdown command used in the script on the command prompot the ssh session I’m working with is offline immediatley and I cannot reach the machine on the network anymore (so far so good and expected) but the power button is still lit. Waiting for a few minutes doesn’t change a thing. If I press the power button for a few seconds the LED of the button is off. Only after doing that I can startup the machine again by pressing the power button.

The reboot command works as expected and performs a quick reboot of the system.

Any thoughts on this issue ?

I have burned a clean SD-Card and tried again, taking your route…

I see the same issue now, that you were facing.

You mean the path variable in both scripts?
When I modify the path variable to
PATH=/usr/bin:/usr/local/bin:/home/dietpi
it seemed to work. But I have no pwr-button connected to this pi. (I did not want to mess with my audio player device).

Big thanks to @crieke for his input here, ia am, as i said earlier no expert. I cant seem to edit my first post anymore either.

I’ll take my spare microSD and try and replicate, it’ll be a nice exercise to verify what might have changed.

I just did the edit for you. :wink:

1 Like

I just went through my instructions here and they work fine for me. I did however run into issues with NTPD access, but i did a manual override and set date and time manually.
After that, everything worked fine and the button performs as intended. :slight_smile:
I did NOT select the wiringpi and rpi.gpio software sets from within the dietpi-software however.

I reactivated my RaspDAC recently.

I soon could remember, that I never have been able to get the power button to shut down the RPi properly. So I started to investigate.

I found out that the shutdown command didn’t work because of the error message:

> Failed to set wall message, ignoring: Unit systemd-logind.service is masked.

There was another error message there. I didn’t copy it but it also referred to the fact that systemd-logind.service is masked.

In the end I added the bold lines

echo “RaspberryPi shutdown”
systemctl unmask systemd-logind.service
sleep 1

sudo shutdown -h -P now
exit 0

to the softstop.sh script

After that change the power button shut down and powered off the RPi for the very first time :slight_smile:

Before changing the script I checked the dietpi.txt on the SD card. The line

AUTO_UNMASK_LOGIND=0

was there.

I found a document saying:

Unmask (enable) systemd-logind service, which is masked by default on DietPi

AUTO_UNMASK_LOGIND=0

According to that the serviced-logind.service should have been unmasked. But this was not the case on my system.

Anyway… it works with the change in the script… just in case someone has similar problems in the future.

pj

1 Like