rad10

The final assembled rad10.

Summary

The rad10 project consists of a raspberry pi outputting audio to a speaker via a small amplifier.

The pi takes minimal input - a rotary encoder with a push-button toggle. Rotate to control the volume, push the button to toggle pause/play

A daemon written in C (rad10d) runs on the pi and polls for changes in the encoder or a push of the toggle button. The code is available on gitlab.

The daemon is set up as a service to run at boot. It intefaces with MPD using the API thanks to the libmpdclient C/C++ library.

Audio is output from the raspberry pi 3.5mm audio jack to a single speaker via a small amplifier module.

Initially I found (via dmesg) that the raspberry pi occassionally triggered an undervolt warning. It never crashed, but with some experimenting I found the under-voltage would occassionaly be triggered at higher volumes when the amplifier drew higher currents. I fixed this by switching to a 4A power supply, combined with a big capacitor to help supply peak loads.

I prototyped with a breadboard until I got the code working before making it permanent.

I had been experimenting with some hobbyist-level woodworking so I decided to put it all in a wooden box, most of which is recycled pallet wood. Access to the ethernet and usb ports was retained for alternative connectivity and the ability to play MP3s from a usb drive, but I almost exclusivley use it for playing a few streams over wifi.

Mostly I use this self-contained, wifi-connected setup to stream radio, though it is set to locally mount an nfs share containing my music collection.

There are a few MPD client apps for android that allow finer control of MPD (I like M.A.L.P.) That said, in keeping with the minimalist hardware interface, I created a similarly minimal web interface with a small amount of php, html and css. This WebUI provides the same contol (play/pause and volume +/-), but I also added a few "preset" buttons to launch my most-used streams.


Daemon Installation and Setup

Install the dependencies:

$ sudo apt update
$ sudo apt install pigpio mpd mpc libmpdclient-dev

(Note, mpc is not strictly required for the daemon, but I reccomend it as a useful command-line client for control of mpd, and debugging for a project like this.)

Clone the repo and compile the executable "rad10d":

$ git clone https://gitlab.com/clewsy/rad10d
$ cd rad10d
$ make all

Copy files to the relevant system directories:

$ sudo cp rad10d /usr/local/sbin/rad10d
$ sudo cp rad10d.service /lib/systemd/system/rad10d.service

Enable and start the service:

(This service is created so that the daemon runs at boot).

$ sudo systemctl enable rad10d.service
$ sudo systemctl start rad10d.service


WebUI Installation and Setup

For the raspberry pi to serve content over a browser, you will need to install web server software. The following example uses Apache.

To give the WebUI the ability to execute commands, I used php code. Therefore php will also need to be installed on the pi.

The hardware daemon is not actually require for the WebUI. This interface could be used with any pi running mpd and mpc.

Install the dependencies:

$ sudo apt update
$ sudo apt install apache2 php mpd mpc

By default, Apache will serve up the content located within the "/var/www/html/" directory. The default files installed at this location should be deleted and replaced by the contents of the "webui" directory in the rad10d repository:

$ sudo rm --recursive /var/www/html/*
$ git clone https://gitlab.com/clewsy/rad10d
$ cd rad10d/webui
$ sudo cp --recursive * /var/www/html/.

(Note, cloning the gitlab repo can be skipped if already done to install the daemon.)

The WebUI should now be accessible over your local network.


Gallery