My New Squeeze box Music Server

My first blog post:

For the last year or two i have been running a raspberry pi b based logitech media server.  The system worked well but with the recent release of the new raspberry pi2 Quad core it was time for an upgrade. Here’s an overview of my project .

Shopping list

. Raspberry pi2
. Hifi berry Dac
. Hd4780 16×02 lcd – eBay
. Arduino nano – eBay
. Ir receiver -eBay
. Rotary encoder (not connect at present)
. Level shifter 5 -3. 3v
. Aluminum chassis ( pre amp kit model PGA2311) – eBay
. Bi-stable latching relay  -eBay

The aluminum chassis

I found this on ebay and it seemed to be exactly what was required as it had all the right cut- outs on the front panel. This amp kit chassis  was originally designed to have the lcd attached to a pcb therefore i had to drill and tap new mounting threads for the lcd to be attached. The chassis also came with a push latch on- switch but i was able to convert it into a ‘momentarily push to make’ by simply removing a latching pin from inside the switch.

Arduino and Power control

The main reason for using an arduino is to provide a safe shut down sequence for the raspberry pi. This is done by removing the power a few seconds after sending a halt cmd ensuring that the file system is fully shutdown. Also as the arduino is powered all the time it allows the system to be powered on as well as off via infrared remote. The rotary encoder is also connected to the arduino to save resources on the raspberry pi. The arduino is connected to the raspberry pi via serial port and as the arduino is 5v and raspberry pi is 3.3v a level converter is used.


LCD display
Hd4780 16×02 lcd wired as per the lcd proc user guide with the exception of one pin used by the hifi berry dac hat (GPIO18). This was changed to an unused pin.

As most raspberry pi fans know that the built in audio has improved over the years but its isn’t HIFI quality yet so i decided to use a hifiberry dac . It comes in the b+ HAT format and requires no wiring and best of all sounds great. I followed the guides on the hifi berry website and soon got it working with Sqeezeslave.

In my previous music server i used a 500gb usb drive, this worked ok but again with this new build i decided to try something new and found a sandisk micro 32gb usb memory stick and for somebody with a good size music collection (mp3 format) like myself this is ample! If it runs out of space then i can just simply add an additional stick or connect a hard disk.


In my previous music server i used a pre made image called squeezeplug, but in this new build i decided to start from scratch, i would recommend this for people just starting out as the setup is all menu based.


Logitech media server

Found this good guide to install logitech media server here :

This is a player for Logitech media server.
I used this and not squeezelite due to the built in lcd output option with Lcdproc
Good installation guide here:
Note if you want the Lcd to display the track playing then run with “–lcd”

This is the software for driving character based lcds, theres a few Linux software out there that have options to send data to Lcdproc such as squeezeslave or able to display text via a python script.


 My custom Python script and web interface
The main purpose of this is to talk to the arduino and contains functions for shutdown and receiving the IR remote codes.  Other custom functions include a sleep timer and load default playlist on boot up. Also using Flask – a python library,  to make a simple web base remote interface for functions such as reboot and copy music to pen drive so can play it in a car ect.  Scan library etc show lastfm page for artist currently playing.


Example web interface


Three python libraries are used which will require also installing.
Pyserial : Use serial port in python to talk to arduino
Pylms: used to send cmds to logitech media server players ie. play stop
Flask: used for basic webserver framework in python.

I haven’t yet posed this script online as its very messy and totally tailored to my setup and plan to do a few tutorials on this soon especially the web remote control so keep a watch over this blog.


Samba is a program that lets you share files and folders over your network. The main purpose of installing samba is being able to access the music folder on my desktop so i can easily add new music etc.
This guide seemed to work fine:

Please only use this for reference with the correct manuals for hardware and software. I hold no responsibility to any damage to any equipment caused .





Hey, would you be able to post some links to where you got you parts, and schematics on how you did the power switch etc?

I’ve been looking to do this kind of project for a while, and figured id ask someone who’s done it.


    Hi Tom, glad you found this helpful so far. Most of the parts i got off eBay to be honest. The case came as kit of parts for a pre-amp kit (model PGA2311) i think off eBay, found by searching “amp chassis” . This came with a kit of part include the power switch and other fixings and hardware .

    As for the Power control side I’ve posted a schematic but you can get a pre-made module on the net but it doesn’t have the IR reemote function just a switch.

    Hope that helps and i will try posting a few links.



Not meaning to self advertise but you could just get an ATXRaspi complete with USB output power and illuminated power button. Then your arduino/IR could also tap into that and issue shutdowns wirelessly.


    Felix , this was exactly what i was trying to describe in my reply to tom. May even try one myself in future builds.


Is there any way possible you could show your arduino code? I’ve been working on pretty much exactly the same thing, and I HAD it working, but my IR died and now I’m having trouble getting things to work again. Would LOVE to see how yours compares to what I have.

My code uses the IR to switch on the relay module, powering the Pi. Then when I issue a shutdown from the Pi(running Openelec) the arduino watches the UART TX pin on the Pi, and shuts off the relay 2 seconds after it goes low. Right now, the problem I’m having is the relay immediately resetting when I set it high. I’m waiting on a P-channel FET to come in the mail to see if I have better luck with that.


    Dalton, I try and post my code over next few days. My works a little different to yours as it does not look at the UART TX pins its a bit more basic hence no feedback from the pi: Just before a “sudo halt” is issued it sets a timer off on the Arduino to switch the relay off after say 30 secs in this time linux should of shutdown(i hope haha). I have used this method on a few projects after last year and had no problems at all.

    Is the only connection between the Pi and the Arduino an Input looking at the UART TX pin ?

    In the meantime if you post your code i can try and have a quick look in case something jumps out.



      Wow , did not expect a response, especially that quick. Mine works based on how the UART TX pin works on the Pi. Immediately on bootup, it goes high, save a few microseconds during the boot process, and it stays high until shutdown is complete. By watching that behavior, I don’t need any software on the Pi to make it work.

      I have two different versions of my code that I have tested with, one watching for a digital HIGH/LOW, and one using an analog pin to actually watch the voltage. Both worked at one time and suddenly “changed their mind” and stopped working, without me changing anything.


      // initialize components and variables
      int RECV_PIN = 11;
      IRrecv irrecv(RECV_PIN);
      decode_results results;
      const long StoredCode = 0x20DFA25D;
      const int relayPin = 2; // Relay pin
      const int checkPin = 7;
      int outputState = 0;
      long lastgpioCheck = 0;
      long gpiocheckDelay = 2000;

      void setup()
      pinMode(relayPin, OUTPUT);
      pinMode(checkPin, INPUT);
      digitalWrite(relayPin, LOW);

      void loop()
      // start pi power on check
      if ((irrecv.decode(&results)) && (outputState == 0)) {
      if(StoredCode == (results.value)) {
      Serial.println(“Infrared Signal recieved. Switching relay on.”);
      digitalWrite(relayPin, HIGH);
      outputState = 1;
      // end pi power on check

      // start pi power off check
      if ((digitalRead(checkPin) == 0) && (outputState == 1))
      if ( (millis() – lastgpioCheck) > gpiocheckDelay ) // Only run after gpio LOW for 2000ms
      Serial.println(“Raspberry Pi powered down. Switching relay off.”);
      digitalWrite(relayPin, LOW);
      outputState = 0;
      lastgpioCheck = millis(); // Reset count
      lastgpioCheck = millis();
      // end pi power off check

      The other version is identical, except the “power off” section looks like this:

      // start pi power off check
      int gpioState = analogRead(A0);
      float voltage = gpioState * (5.0 / 1023.0);
      if ((voltage gpiocheckDelay ) // Only run after gpio LOW for 1000ms
      Serial.println(“Raspberry Pi powered down. Switching relay off.”);
      digitalWrite(relayPin, LOW);
      outputState = 0;
      lastgpioCheck = millis(); // Reset count
      lastgpioCheck = millis();
      // end pi power off check


        Apologies my reply hasn’t been as quick as the first. At first look at your code nothing really stands out why it wouldn’t work. One problem i could see if you turn it on without using a remote outputState would not = 1
        resulting it not shutting down not enabled ? Also are you using pull up resistors ?
        Sorry to suggest this but sometimes it can be the simple things.

        Any difference with a FET?

        Will have to try and hook it up for myself when i get a change.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.