Sad because my 7.1 receiver broke down and get a repair offer pricier than a new High end receiver ... my first decision was to scrap and recycle it.

But looking at that that case full of electronic garbage, looking to a spare Raspberry PI 2 some thoughts started to fly around my head and MyPIAmp project started to take shape....

I would need to get a cheap class D amplifier, reuse whatever I can from what inside that case and build my own cheap and customized Stereo System... after all I just need 2 channels to listen my music in my backyard where I don't have any audio system there...

The requirements...

0. Music player, capable of reproduce high end sampling rate, let's say, up to 24bits/192Khz. this means that I don´t want to be limited on the source:

"capable of reproduce DVD-Audio, some LPCM DVD tracks, BD-ROM (Blu-ray Disc) audio tracks, and HD DVD (High-Definition DVD) audio tracks, High-Definition audio recording devices and audio editing software. This sampling frequency is four times the 48 kHz standard commonly used with audio on professional video equipment." View source
  1. Headless and autonomous System - Meaning that it should operate without Monitor and keyboard and without network connection. To achieve that I need to add a capable storage that is capable to mirror my Music Database when network connected and a control system that enables minimal operation without Volumio interface that is network powered (http client)
  2. Built in amplifier with Line Out and Speaker Out option to connect to 2nd Amplifier system
  3. Analog audio input for Mobile devices or MP3 / CD players connection and reproduction
  4. USB input for keyboard (emergencies console login without open the box) and USB dongles with Audio files to play.
  5. HDMI Output for emergency console and future Media player?
  6. ON/OFF switch to cut of power (No neet do perform Raspberry pi shutdown. It must handle that :-)
  7. Ethernet port for wired lan connection
  8. [OPTIONAL] WIFI dongle for wireless lan connection (this is optional as I don't want to add delay on Raspberry boot times)

Step 1: The High Level Project

based on the requirements I've buiil a schematic of what needs to be done and made my hardware/software selection :

  • RPI with Volumio as it is light and simple. - no aquisitons need to be done
  • DAC with IR receiver to be able to control the system with a IR remote control and comply with requirements - to be aquired
  • 2x16 Character LCD for headless system control interface. Need USB interface as I dont want to solder anything on top of DAC - to be aquired
  • Remote control - Reused one from apple TV that is barely used.
  • Class D amplifier - to be aqquired
  • Input switch - Reuse a broken one with four inputs. Use the 3P4T switch with custom cabling and the power unit to power 4 status leds. Add extra led for power on signal. - no aquisition needed
  • On/Off Switch - Reuse some 220AC with red button power switches that I have available - No aquisition needed.
  • 250Gb USB Hard disk - No need to aqquire
  • USB powered hub - No need to be aqquired
  • WIFI dongle - Available
  • Ethernet extension cable to connect RPI to back panel - Available
  • HDMI extension cable to connect RPI to back panel - need to aqquire
  • 2 Power transformers - 1x12Vdc & 1x5Vdc
  • 2 AC plugs
  • electrical cable for AC power
  • wires from old UTP cable for internal connections
  • Some custom adaptations to mount the input switch in the case and volume control from a D-shape's to 6mm knobs...
  • Other custom adaptations to fix everything inside the case...

Reuse from old receiver:

  • Speaker terminals
  • RCA connectors
  • Phone jack
  • USB plug
  • Leds
  • Case

It was not possible to use amplifier modules neither Power Supply and rectifiers from old receiver as they were not working...

and with that a List of materials was defined:

Hardware list

1. Raspberry PI 2 RevB
2. Raspberry pi B+ 2B HIFI DAC + Audio Sound Card I2S Interface Special PCM5122
3. TPA3116D2 Class D Digital Stereo Amplifier Board 50W+50W 12-24V Dual Channel Car
4. Audio Input signal Selector Relay Board / Signal Switching Amplifier Board+ RCA (Broken. Used only for Powering the leds and the custom wired 3p4T selector)
5. Apple TV Remote
6. Box and some reused components of a broken Pioneer VSX-920-K 7.1 receiver
7. Adafruit USB + Serial Backpack Kit with 16x2 RGB backlight negative LCD
8. 12V DC power transformer
9. 5V 2.5A power transformer
10. USB powered hub
11. Other small parts and accessories

Step 2: The Low Level Project

After defining and collecting all the hardware pieces, it came the time to put everything together.

As this project is performed on my available time, it took me just to assemble everything inside the box a couple of months, because most of the work was performed during weekends and late in the evening...but it worth it...

first of all, and based on High Level Plan, I've defined the input selector part, just for understanding how to wire the 3P4T selector. I've wired Right and Left Channel and the 12VDC. For the first 2 same ground was shared and for 12VDC the reference was also shared.

The 3P4T selector color scheme is the same as wires used.

After that I've draw the overall schematic and build the system based on that... Some pictures highlight some of the adaptations done...

Build is like everything. Just do your best...with what you have

Step 3: Software

On this section, are described all the steps to put the logic onto all the hardware setup and all the customizations done in this project.

Software Levels

  • 3.18.5-v7+ #748 SMP PREEMPT Wed Feb 4 21:33:52 GMT 2015 armv7l GNU/Linux
  • Lirc armhf 0.9.0~pre1-1.2
  • LCDproc 0.5.7
  • python-lirc_1.2.1-1_armhf.deb
  • Volumio 1.55PI

Step 4: Install Volumio and Configure DAC

STEP 1: Install Volumio

1.1 Just follow instructions as described in Volumio.org

Step 2: Install DAC

Assumption: DAC is already physically installed on your Raspberry PI 2

Installation the DAC on this software is relatively simple:

2.1   > Access Volumio pointing your browser to <a href="http://volumio.lan"> http://volumio.lan </a> or <a href="http://<your.rpi.ip.address"> http://<your.rpi.ip.address></your.rpi.ip.address></a>>
<a href="http://your.volumio.IP.address"></a>2.2   > Go to  [Menu] --> [System]
2.3   > Go to  [Activate I2S Driver] and select [HIFIBerry DAC+]
2.4   > Hit [Apply]
2.5   > Reboot your RPI and you're done

Step 5: Prepare for Your Remote - Install Lirc

Assuming that you are using mentioned software levels, this is "Jessie" linux version. Some stuff has changed with it and we will need to go through slightly different process than in older versions...

3.1    > sudo apt-get update
3.2    > sudo apt-get install lirc
3.3    > sudo nano/etc/lirc/hardware.conf

And change below entries


Save and close editor

(Ctrl-O / Ctrl -X)

As Debian Jessie uses "Device Tree, overlays and parameters" system configuration, we need to add device overlay for RPI Lirc. lirc overlay uses GPIO pin 17 and 18 by default.

Make sure that lirc-rpi entry is inserted before hifiberry-dacplus entry and that you change default gpio pins as they collide with DAC ones. Some nasty results were experienced with this….

Gpios pins used were gpio_in_pin=26 and gpio_out_pin=27.

3.4 >sudo nano /boot/config.txt 

Save and close editor (Ctrl-O / Ctrl -X)

3.5 > sudo reboot

You should get lirc working by now...to verify use:

3.6 > ls /dev

You should see a list of /dev entries. Search for '/lirc0' entry. If you see it, you've got it. Now let's if it is working properly…

3.7 > sudo modprobe lirc_rpi 

Test it

3.8 > mode2 -d /dev/lirc0

Press your remote keys to see if some pulse space messages appear…

Step 6: Setting Up Your Remote

The best way to setup your remote is by recording each key press.

First, plan ahead what you want to do with all the remote keys.

In this case is easy as apple remote as only a few keys (7 keys only). Just like to keep UI simple…

Before record your remote keys you need to stop lirc.

3.9 >sudo /etc/init.d/lirc stop

Record your keys

3.10 >irrecord -n -d /dev/lirc0 /etc/lirc/lircd.conf

For apple remote Following names were recorded:


To record the keys, just follow the instructions presented on the screen:

Start Lirc

3.11 >sudo /etc/init.d/lirc start

Check if you’re remote is working. Issue the below command and press your remote keys. If it is working you should receive proper feedback on your screen.

3.12 >irw

Now you want to remote control your mpd under volumio. To achieve that you must edit lircrc file to map you’re named keys with Music Player Daemon (MPD) actions.

Take a note on prog = irexec entry. That entry will be important for controlling your LCD at a later stage. Also note that you need to map the button entry with the recorded keys in step 3.10

3.13  >sudo nano /etc/lirc/lircrc
prog = irexec
config = mpc toggle
prog = irexec
button = KEY_NEXT
config = mpc next;mpc play
prog = irexec
config = mpc prev;mpc play
prog = irexec
config = volume +1
prog = irexec
config = volume -1
prog = irexec
button = KEY_SHUFFLE
config = mpc shuffle
prog = irexec
button = KEY_PLAY
config = mpc play

*Note: On KEY_VOLUMEUP and KEY_VOLUMEDOWN the ‘config’ entry do not include ‘mpc’ as the volume control is in charge of a python script instead of direct IR command.

Save your file with Ctrl-o and Ctrl-x and restart your system

3.14 sudo reboot

Now you should have your Volumio system controlled by your remote.

Step 7: Control Your LCD - Install Lcdproc

LCDproc is a client/server suite including drivers for all kinds of nifty LCD displays.

The server LCDd makes it possible to display text and other data on an LCD display. As well LCDd can handle certain input devices.

4.1> sudo apt-get update 
4.2 > sudo apt-get install lcdproc

Note : On changelog reading exit with “q” not “ctrl-C”

Connect the LCD backpack to a USB port, then type:

4.3 > dmesg

Near the bottom of the list you should find some references to a USB device. One of the references should include a tty name… for example:

[ 6.263337] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device

Take note on the name "ttyACM0" or whatever other name that may have been assigned to your LCD Backpack. You will need it for configuring the software.

Configure LCDd, the LCD daemon

LCDd will control your LCD and uses LCDd.conf file. The location of this file may vary depending on the installation method that you've used. Best way to find it is issue the command:

4.4 > sudo find / -name LCDd.conf -print

Most likely you will find it on /etc/LCDd.conf

Edit the file (note that this file must be edited as root)

4.5 > sudo nano /etc/LCDd.conf
## This file was written by cme command.
## You can run 'cme edit ' to modify this file.
## Run 'cme list' to get the list of applications available on your system
## You may also modify the content of this file with your favorite editor.




Now let's do a test run

4.6 sudo /etc/LCDd

If it throws an error message the most probable cause is that you specified the wrong device, or the driver path does not point to the correct driver place (or misses the end slash) or LCDd.conf is on the wrong location…

If everything runs ok, you should view on your LCD a greeting message from LCDd server that is waiting for a client to bind and start to display the messages…

Issue Ctrl-C to stop the server (if you have uncommented entry Foreground=yes otherwise you should issue sudo service LCDd stop) to complete LCD configuration

If you made your install using apt-get, it should be already auto-starting…

Step 8: Input Control - Lirc Driver With LCDd

The lirc driver enables your remote to interact with LCDd server and any client that can handle inputs. For this to work you need a working lirc configuration. Refer to step 3 of this guide

2.1 Build LCDd with the lirc driver

First you need to add lirc to the --enable -drivers= then run make.

Configure LCDd to use lirc driver

2.2  > sudo /etc/LCDd.conf 

Add following entries


Just as follow LCDd.conf file

## This file was written by cme command
## You can run 'cme edit ' to modify this file.
## Run 'cme list' to get the list of applications available on your system
## You may also modify the content of this file with your favorite editor.

Step 9: Control Logic - Python Script

Now it's time to add the logic behind your system in order to interact and control it with your remote, specially when no network connected.

Build a python script both to control your LCD and some functions of MPD. To achieve that is needed to include the lirc module to python in order to capture lirc triggers into python script.

python-lirc` is in the main repositories for Raspbian. If you're on a RaspberryPi you can just run:

6.1 > $ sudo apt-get install python-lirc

Otherwise, download the latest release from

(https://github.com/tompreston/python-lirc/releases) and install with:

6.2 > $ sudo dpkg -i python-lirc_1.2.1-1_armhf.deb 

To put everything working a python script is needed to be able to control myPIAmp using remote and display custom messages and do interact with the system

Main objective is:

  • Display custom information about what is playing
    • Screen 0, 1 and 2
  • Load 2 kinds of playlists
    • Screen3: Load USB disk Music Directory
    • Screen 4: Load radios.m3u custom playlist
  • Change 2 playing parameters
    • Screen 5: Random = on | off
    • Screen: 6: Crossfade = [0,5,10,15,20]
    • Screen 7: Volume [0..100%]

UI screens and workflows are represented on attached diagram.

check the python script in the attachments

Put the script on /home/volumio

Make it executable

6.1  > Chmod +x <scriptname.py>

Execute as daemon it this way

6.2  > ./<scriptname.py>&

Make it executable at boot level

> sudo nano /etc/rc.local

And just before exit(0) insert your line


et voilá...

Step 10: Sync Your Files - Sync HDD Local Music Folder With Your Remote Music Folder

Create a shell script to sync your local USB drive with your music server directory. all files are located in a NAS server that supports SSH access. in this way I've used rsync command. Please refer to rsync command for further info.

7.1  >sudo nano syncmypiamp.sh
#Script to sync local HDD with NAS Audio Files database
echo "Start"
echo “Syncing USB HDD contents with Music Server Database…”

for dir in /volumeUSB1/usbshare/iTunes/iTunes\ Media/Music ; do
rsync -avz --ignore-existing --protect-args -e "ssh -p <ssh port>" <user>@<ip address>:"$dir" "/mnt/USB/"
echo “Syncing complete!”
echo “Updating MPD database! Please wait that Update completes before loading your playlist…!”
echo “Bye now!!!”

and make it executable

7.2  >chmod +x syncmypiamp.sh

Execute it for sync. This script is manually executed and it’s intention is to sync your local DB with your NAS music server everytime you update it or when you get myPIAmp on line…

First time run will take long... depending on the size of your DB.

Syncmypiamp.sh is located on Volumio home folder

$ ~/

$ /home/volumio/

1.2  /home/volumio/./syncmypiamp.sh

Step 11: Web Radio - Radio Playlist

On this project I used a national FM radio list and beside there are a lots of default internet radios on volumio WEBRADIO folder pre-installed, nothing as have on a custom playlist a set of specific stations.

For that was used an m3u playlist with selected contents… and with information to be displayed on MyPIAmp LCD, if no info is available from the radio station itself!

You should place your m3u playlist into /var/lib/mpd/playlists/

see m3u file in attach

now enjoy...

Step 12: Conclusion

This project was a big fun to build.

A lot of improvements can be made, especially on the control and logics.

I'm wonder to include a Media player all together in the system or a 2nd RPI on the same case for that... But that's not a priority.

Priority now is to recover a very old speakers with a set of car JBL drivers that are stored in the garage and mount them on the speaker boxes. Install them on my backyard with a quick system to connect MyPIamp to the speakers and enjoy music while outside...

Most of this procedures were taken out of the net, I've just adapted them, collected and share them.

Do the same

and enjoy!

<p>thank you @pparreira</p><p>no, is not working I have IQaudiODAC for my DAC on volumio </p><p>good job and good explication </p><p>very cool projects</p>
<p>super !!</p><p>But I had only one problem with Volume Up ans down with my remote !! <br></p><p>all work good , </p><p>any help will be appreciated</p>
<p>Hi,</p><p>Please check in Volumio options - Playback -&gt; Volume control mixer to which option is selected: If Disabled, you cannot control volume, if Hardware, must be a compatible DAC, if software you should be able to control it with the remote, but at a cost...</p>
<p>Cool pi amp project.</p>

About This Instructable




More by pparreira:MyPIAmp project - RPI player and amplifier 
Add instructable to: