I’ve redesigned my internet radio project – now it features an amplifier with 12v 2A power supply, which is split off to a 5v UBEC to power the Pi via its GPIO pins. The amplifier powers the speakers so the only USB connections are the DAC and wifi dongle.

img

The sound is much louder and there is no hum or whine like before – I think that was a ground loop or antenna issue with all the USB cables and hub.

I’ve got to solder a little daughterboard together to tidy up the power splitter (shown on breadboard in the photo) and replace the wires on the speakers, as they are so brittle one has already fallen off. I’ve also got to add a pushbutton and voltage divider for controlling the play/pause/stop, probably on the same board.

I also am now using a i2c backpack for my LCD, so only need a set of 4 dupont cables instead of a dozen or more cables, potentiometer etc. I wrote a simplified version of the pi-libs library and made some minor changes to my main pi-radio script here.

As I had lost the SDcard image of my previous installation, I had to start all of the configuration from scratch, so made sure to note everything down this time!

  1. Install dependencies:
dpkg -i python3-rpio_0.10.1_armhf.deb python-rpio_0.10.1_armhf.deb
apt-get install mpd mpc autofs
  1. Edit /etc/mpd.conf
music_directory "/mnt/data2/music/sorted"
bind_to_address "any"
auto_update "yes"
zeroconf_enabled "no"
audio_output {
	type		"alsa"
	name		"DAC"
	device		"hw:0,0"	# optional
	format		"44100:16:2"	# optional
	mixer_device	"default"	# optional
	#mixer_control	"PCM"		# optional
	#mixer_index	"0"		# optional
}
  1. Create MPD database:
mpc update
  1. Comment out/add these lines in /etc/modprobe.d/alsa-base.conf to make the DAC the default device with lower latency:
#options snd-usb-audio index=-2
options snd-usb-audio nrpacks=1
  1. Comment out these lines in /etc/modprobe.d/raspi-blacklist.conf to stop blacklisting the I2C/SPI modules:
#blacklist spi-bcm2708
#blacklist i2c-bcm2708
  1. Add these lines to /etc/modules to load the I2C kernel modules on boot:
i2c-dev
i2c-bcm2708
  1. Setup autofs to automatically mount the NFS4 fileserver:
echo 'data2 -fstype=nfs4,hard,timeo=60,ro,rsize=32768,wsize=32768 vader:/data2' > /etc/auto.nfs
echo '/mnt /etc/auto.nfs --timeout=60 --ghost' > /etc/auto.master
  1. Copy everything into place and setup the init script to run on boot:
cp pi-radio /etc/init.d/
cp radio.py pylcd2.py /usr/local/bin/pi-radio
cp pylcd2.py /usr/local/bin/
cd /usr/local/bin/
chmod 755 pi-radio pylcd2.py
update-rc.d pi-radio defaults
update-rc.d nfs-common enable
update-rc.d rpcbind enable

Update: I’ve soldered/heatshrinked everything together and it works wonderfully! I didn’t use a resistor divider for the pushbutton, I just connected it to 3.3v, GND and GPIO24 using dupont cables and a pullup resistor, which actually makes it nicely modular. I could add another button by making another board in the same way and linking 3.3v/GND via headers like here.

I’ve got to gluegun some of the connectors to give some strain relief and then look into mounting everything in a case. At the moment everything but the LCD and button fit in the box I bought.

img

Update 2: I’ve switched to 3 buttons now (uses 3 GPIO pins plus 3.3v/GND) so we have play/pause, skip track, stop/shutdown. I noticed that the speakers sound much better when placed on a wooden table, so I think I’ll have to look for an old wooden subwoofer or speaker box I can gut and screw everything inside.