Introduction: Raspberry Pi DAC Hat Case From PVC Wall Box
I used an inexpensive Wall Light Switch Box as a Raspberry Pi and DAC Hat Case with space to include a Power Switch as well.
The Raspberry Pi 3 has a board dimension of 56mm wide and 85mm long and I recently discovered that my PiFi Plus DAC hat and the Raspberry Pi will fit into an inexpensive (less than $ 0.50) PVC plastic electrical household wall box used to mount light switches - the one I bought had an outside dimension of 105mm x 60mm x 45mm, and on the inside it was 56mm wide and 101mm long - this means the Pi board will fit (tightly).
Step 1: Construction
The Pi is mounted on four short 5mm spacers. The top of the wall box was made from a sheet of thin 0.9mm white ABS plastic which can be easily cut and drilled. Please refer to the series of photos for more details on how to mount the Pi and its DAC hat.
The PiFi DAC+ is an inexpensive substitute for the HiFi Berry Pi DAC+ Hat and can be configured in exactly the same way on the Raspberry Pi running Raspbian Stretch - replace the line dtparam=audio=on from /boot/config.txt if with dtoverlay=hifiberry-dacplus.
Create a file asound.conf in /etc with the following lines:
type hw card 0
type hw card 0
and reboot - the green light of the DAC should then appear.
You can use for example nano th edit the two files: sudo nano /boot/config.txt and sudo nano /etc/asound.conf
The PiFiDAC+ can be obtained from itead.cc or from banggood or from seeedstudio.com for about $6 to $35.
I used a Dremel wheel to cut out the larger rectangular openings, and a step-drill to make the larger round openings - PVC is very easy to drill, cut, file, sand and glue.
The photos included give details of the progression from the bare box to the finished product.
I included a power switch for the Pi on the front panel - this is directly connected (soldered on the bottom of the Pi's pcboard), to GPIO pin 4 (+5v). This and a wire from GPIO pin 6 (Ground) is then soldered to a normal power barrel connector mounted on the back panel.
This socket can be used in one of two ways:
1. Use the normal Pi micro-USB connector to supply power to the Pi - the barrel connector will then output +5v to for example a notebook hard disk power supply.
2. Use the barrel connector to supply power to the Pi directly.
The case has a large round opening on the side opposite to the four USB connectors. This is used for ventilation, and also as a window to the Pi's two status lights (red and green), but most importantly the Pi's SD card can be removed and inserted through this hole using a tweezer.
The ventilation seems to be adequate without a fan or a heatsink for the Pi - after an hour of playing flac and mp3 files the CPU temperature varied between 49 and 51 degrees Celsius. There is space to fit a small fan underneath the top cover in the section above the Pi's USB connectors - a fan such as those used for hdd coolers would be suitable and some will operate silently if powered from 5 volt instead of 12 volt.
I intend to use this Pi DAC Box with a 1 TB notebook drive to play music through my stereo amplifier and I must still configure VNC on the Pi and VNC Viewer on a PC, so that I can use the Pi headless from a Windows PC to play music.
I gave some details and additional links on how to boot the Pi from its SD card but use a USB Hard Disk Drive for the Root File System and Data Disk in a previous instructable.