(HowTo) PiZeroW + pHatDAC + MPD + MPDroid


It is not really a project. I just find it good, not very difficult to setup, seems nobody share the same thing here before, I come to fill the gap.

I have my PiZeroW running headless, only power-line in, a 32G music usbkey (with the OTG Converter Shim), line out from pHatDAC to a mini-amp. I use my Android phone to select what music to play.
(Planning to use Blinkt as VU meter, TouchpHat to poweroff and maybe something else. Meanwhile, I ssh in to poweroff.)

To Install MPD. (I use raspbian, mpd installed is ver 0.19.1-1.1 and it works fine for me.)

sudo apt-get install mpd

Make sure you do NOT run mpd as a system daemon which will bring you tons of file permission problems. So,

sudo systemctl stop mpd
sudo systemctl disable mpd
sudo systemctl stop mpd.socket
sudo systemctl disable mpd.socket

Make a new home for mpd settings

cd ~
mkdir -p .config/mpd/playlists
cp /usr/share/doc/mpd/examples/mpdconf.example.gz ~/.config/mpd/.
cd .config/mpd
gunzip mpdconf.example.gz

You should now have a file mpdconf.example there, edit it so that it has

 music_directory      "/media/pi/32GKEY/musicbox"
 playlist_directory   "~/.config/mpd/playlists"
 db_file              "~/.config/mpd/database"
 log_file             "~/.config/mpd/log"
 pid_file             "~/.config/mpd/pid"
 auto_update          "yes"
 audio_output {
  type        "alsa"
  name        "My ALSA Device"
  device      "hw:0,0"
  mixer_type  "software"	

I run the following command to filter out comments and blank lines for easy checking

cat mpdconf.example | grep -v “^#|^$”

Your usbkey should be auto mounted to /media/pi/keyLabel/nameYouGave

To autostart mpd after boot, edit ~/.profile and append the following line

mpd ~/.config/mpd/mpdconf.example

My headless pi boot to cli, less overhead and better performance, but you can’t use other autostart methods that depends on X.

Reboot, then

ps aux | grep mpd

to see if your mpd command is running. You may want to check out ~/.config/mpd/log too.

On Android, install MPDroid, input the ip addr of your pi and port 6600. That’s it, enjoy.