If for whatever reason, you need an analog audio output on your Raspi and the internal one sounds too bad for your taste, here’s how to connect one of those cheap I2S modules (Aliexpress) to your Pi.

Physical connection

DAC ModuleRaspberry Pi 3
VINPin 2 (5V)
GNDPin 6 (GND)
LCKPin 35
DINPin 40
BCKPin 12

The PCM5102 will generate SCK by itself, but it needs to know that it should do that, this is done by connecting SCK to GND. Otherwise your audio output will sound like a distorted, bass-boosted remix (one could, of course say, that this is a nice feature :D).

Refer to pinout.xyz if you aren’t sure about the Pi’s pin numbering.

Software setup

This guide explains it quite well, but I will summarise it here, in case something ever happens to that link.

Editing boot.txt

Run this command to open the file in a text editor:

sudo nano /boot/config.txt

You will need to change the following things:

Uncomment (remove the # before the line):


Comment (add a # before the line):


Append this to the end of the file:


Creating asound.conf

Run this command to open the file in a text editor:

sudo nano /etc/asound.conf

And paste the following:

pcm.!default  {
type hw card 0
ctl.!default {
type hw card 0

Now reboot your Raspberry Pi

sudo reboot

Testing our changes

Use the command aplay -l to list your audio devices, if your changes were successful, the output should look like this:

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

You can try playing a wav file using aplay filename.wav or install mplayer to play other file types.

Leave a Reply

%d bloggers like this: