24-bit, 192KHz Audio for the Raspberry Pi Zero with the pHAT

pHAT DAC for Raspberry Pi Zero
www.pdf24.org    Send article as PDF   

The pHAT provides a super affordable high-quality DAC for your Raspberry Pi. It pumps out 24-bits at 192KHz from the Raspberry Pi’s I2S interface on its 2×20 pin GPIO header.

Use pHAT DAC to build a tiny, lush-sounding streaming music device, or use it with Scroll pHAT to make a beautiful spectrum analyser!

Features

  • 24-bit audio at 192KHz
  • Line out stereo jack
  • Optional landing for dual RCA phono connector
  • PCM5102A DAC over the Raspberry Pi’s I2S interface
  • pHAT DAC pinout
  • Compatible with Raspberry Pi 3B+, 3, 2, B+, A+, Zero, and Zero W
  • Female header requires soldering

Software

pHAT DAC doesn’t require a Python library like most of our other HATs and pHATs, but does require configuration to work properly. We’ve put together a slick one-line installer to get everything set up just right. See the tutorial below for more details.

pHAT DAC for Raspberry Pi Zero

The pHAT software does not support Raspbian Wheezy.

This guide will explain how to get pHAT DAC up and running on your Raspberry Pi using the Raspbian operating system.

Before you start, you should make sure that Raspbian is up-to-date, either by following our guide or downloading and installing the latest version.

pHAT DAC provides a line-level output, which means you should connect it to some speakers or a stereo system ready to test your set up. Don’t use headphones!

Note that this configuration will disable the default sound modules on your Pi, so that sound will only play through the DAC.

pHAT for Raspberry Pi Zero

Automated Set Up

First you should fire up Terminal on your Raspberry Pi. If you boot up to it, great, you’re set, if you boot to desktop you can find it in the Raspberry Pi menu under Accessories.

The easiest way to get going with your shiny new pHAT DAC is to use our one-line installer, like so:

This script will set everything up for you whether you are running Raspbian Wheezy or Jessie (including Jessie Lite). You will need to reboot your Pi after the script has completed.

Once that is done and your Pi has been rebooted you may, if you like, run the above script again and it will offer you to test your setup summarily. PLEASE set your speakers at a low volume first however, then progressively raise the levels if you can’t hear any sound coming out the pHAT DAC!

Manual Set Up

If you are interested in what the script mentioned above is doing, keep reading, though for most users that isn’t necessary, unless you can’t hear any sound coming out of the pHAT DAC after running the automatic set up steps as laid out above.

Note that those instructions were initially written for Raspbian Wheezy and meant as a troubleshooting guide outlining the principle of exchanging the default bcm2835 chip for the pHAT DAC to pipe audio through. Additions were made to cover Raspbian Jessie however.

Step 1: All The Modules

In Terminal, type: sudo nano /etc/modprobe.d/raspi-blacklist.conf to open the module blacklist file. This file prevents certain modules from loading at startup. With the file open, comment out the lines corresponding to the modules we want to load by changing:

To:

If some or all of those entry are not present, don’t worry, you are trying to disable those modules anyhow!

Finally, close nano by pressing CTRL+C followed by y for yes, and finally enter to confirm. You’ll need to remember how to do this in the next few steps, too.

Step 2: Be Gone, Default Sound

Still in Terminal, open the modules file by typing: sudo nano /etc/modules. This file, in contast to the blacklist, lists modules which we do want to load. We’re going to remove the default sound driver with a comment, so change the line:

To:

To prevent it loading (this entry should exist, if not you are likely running Raspbian Jessie, which configures the audio chip differently – this will be handled by Step 4).

Step 3: Sound Config

Finally, create a new asound.conf by typing sudo nano /etc/asound.conf and entering the following:

Step 4: Device Tree

The last step is to edit your config.txt, type sudo nano /boot/config.txt and add the line:

pHAT DAC uses the same hardware as HiFi Berry, so we’re borrowing their device-tree overlay!

While you have that file open, check for the following entry, and if it exists, comment it out:

Reboot

Finally, reboot your Raspberry Pi and with any luck your audio should now blast through your connected speakers.

Previous Post

WS2812 Addressable LEDs: Raspberry Pi Quick-start Guide

This tutorial is aimed at getting some instant gratification from your WS2812 LEDs (trade name: neopixels). I'll briefly cover a bare-bones setup for Raspberry Pi. If you've never used a ... Read more

Next Post
First Bash Script with Raspberry Pi

Writing Your First Shell Script with Raspberry Pi

In this tutorial we'll be writing our first bash script for Raspberry Pi. We'll create a directory to keep this and future scripts, write the actual script, and set it ... Read more

Short URL: http://tinyurl.com/ycqcn9xy

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.



Do NOT follow this link or you will be banned from the site!