Raspberry Pi GPIO Audio Amp control with relays using squeezlite

I have had a project in the making for some time. We use a Raspberry Pi with a Squeezeplug image to run Squeezelight on it to do basic audio out in our bathroom. As an amp I use the Dayton DTA-1. The amp has to be manually turned on and off each time we use it. This is subobtimal, as the whole idea behind the Logitech Media Server is to be able to use an app to use it.

While researching I came across the Squeezelite RPI GPIO project. It is a drop in replacement for the squeezelight binary provided by the Squeezeplug guys. To get it to work you need to change the code in a few places.

First log into your Raspberry Pi as root.

Get the latest git version of Squeezelite RPI GPIO:
git clone https://code.google.com/r/phermann2-squeezelite-rpi-gpio/
cd phermann2-squeezelite-rpi-gpio/

Then edit the Makefile:
nano Makefile

Change the CFlags to this:
CFLAGS ?= -Wall -fPIC -O2 $(OPTS) -DGPIO -DDSD -DLINKALL -DRESAMPLE -DFFMPEG
notice the -DGPIO, this gives you access to the desired functions.

compile with this command
make

now make a backup copy of your current squeezelight binary:
cp /opt/squeezelight/squeezelight /opt/squeezelight/squeezelight.original

edit the start script of squeezelight, as we need root rights
nano /etc/init.d/squeezelite
all I did is add a
USER=root
after the first fi in the file… it overrides everything it detects automatically.

restart the squeezelite service to check if it worked.

You now need to connect pin 18 on the Raspberry PI to the input on your relais.

Relais for a Raspberry Pi Squeezbox Amp control

In my case I got a board for Arduino with 5 Volt relais and 3,3 volt pins. I took an old power cable and spliced it to attach it to the fist relais and added a socket for the power source of the amp.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.