7

I purchased a PCM5102 for my PiZeroW, but having problems finding

  1. complete driver software information
  2. voltage information
  3. wiring information.

I chose this particular unit because they seemed very popular on Ebay when talking about adding I2S sound to Raspberry Pi.

With so many on sale, I guessed instructions would be easy to find.

enter image description here What is the Device Driver / Device Setup

I have been watching the Adafruit setup of a different I2S unit. Looking for hints. https://www.youtube.com/watch?v=kkaYTIC0RoQ

aplay -l

This should show available sound cards. But I don't get any. I suspect I have the wrong boot config. I do have I2S enabled in the /boot/config.txt, also set the

dtoverlay=hifiberry-dac

I have setup /etc/asound.conf as well.

What is the Vcc Voltage for this card? 3.3v or 5v?

The raw chip looks to be 3.3v, according to the datasheet, but there are many surface mount resistors on the card, any could be used to pull down a Vcc of 5volts to 3.3v. http://www.ti.com/general/docs/datasheetdiagram.tsp?genericPartNumber=PCM5102&diagramId=SLAS764B

I've gone conservative for now, picking 3.3v. Trying to keep the magic smoke within the unit:)

Wiring the PCM5102 to the PiW

Other than Vcc, the other wiring I deduced from here.

http://masterandrey.com/posts/en/dac_raspberry_pi_pcm5102/ http://www.denshi.club/pc/audio/raspberry-pi-2i2s-dac.html

Is the MCK (SCK) line to be connected, or left unconnected as suggested by www.denshi.club ?

Symptoms

No sound when using headphones plugged into the 3.5mm jack.

The led on the card comes on.

Sorry, I don't have a scope, so I'm not able to test the I2S lines.

aplay -l

Not seeing any cards listed.

1
  • "With so many on sale, I guessed instructions would be easy to find." -> Next time check first ;)
    – goldilocks
    Commented Dec 7, 2017 at 14:59

5 Answers 5

8

I was able to make this unit work with my Raspberry Pi 3 using volumio and osmc without the need of any software tweaking. I must say that it sounds very good on both distributions.

While using both the distributions, I selected the HifiBerry DAC profile from system settings.

Note that my unit came with the jumpers for the extended headers already shorted. In the picture below, you can see the little jumpers.

For powering up the board:

There's a 3.3V regulator already on the audio board and you can leave it unconnected. I ended up connecting the 5V rail from the rpi to the VIN of the DAC and it works just fine. The blue LED on the DAC should light up when it's powered up correctly.

Wiring Pinout:

DAC BOARD   > Raspberry Pi 3 Model B connector J8
-----------------------------------------------
SCK         > Not wired (Internally generated)
BCK         > PIN 12    (GPIO18)
DIN         > PIN 40    (GPIO21)
LRCK        > PIN 35    (GPIO19)
GND         > PIN 6     (GND) Ground
VIN         > PIN 2     (5V)

-----------------------------------------------
FLT             > Not wired 
DEMP            > Not wired 
XSMT            > Not wired 
FMT             > Not wired 
A3V3            > Not wired 
AGND            > Not wired (Same as headphone out) 
ROUT            > Not wired (Same as headphone out)
AGNDL           > Not wired (Same as headphone out)
LROUT           > Not wired (Same as headphone out)

This setup works while using this unit Audio device enumeration returns the following:

volumio@audio:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I hope this helps get things moving.

5
  • I corrected the ground wire pin above (ground is 6), and typo in Volumio.
    – null
    Commented Dec 11, 2017 at 12:43
  • The hardware setup above is verified. I already had a running system so I just did the system setup manually, and used mplayer. Instructions here for the setup support.hifiberry.com/hc/en-us/articles/…
    – null
    Commented Dec 11, 2017 at 12:46
  • Thanks for the instructions, edits and congratulations on getting it to work. Commented Dec 12, 2017 at 13:57
  • I had to connect SCK to GND to make the module work with my Pi Zero W.
    – javaxian
    Commented Jan 20, 2019 at 17:13
  • Thank you so much for the photo of the pads - I had none connected (and no instructions!) Commented Jan 4 at 2:38
10

On these purple PCBs there are 5 sets of bridging pads.

On the front (component side) there is one pair of pads which may be bridged to tie the SCK (system clock) low. This will force the PCM510x to generate the system clock using its internal PLL. You may bridge these pads to remove the need for an external SCK or connect the SCK pin to ground (0V). The Raspberry Pi does not supply a system clock so this will be required to connect to the Raspberry Pi.

On the back (non-component side) there are 4 sets of 3 pads for the 4 functions:

  1. FLT - Filter select : Normal latency (Low) / Low latency (High)
  2. DEMP - De-emphasis control for 44.1kHz sampling rate: Off (Low) / On (High)
  3. XSMT - Soft mute control(1): Soft mute (Low) / soft un-mute (High)
  4. FMT - Audio format selection : I2S (Low) / Left justified (High)

The centre pad is connected to the corresponding pin. Each of these function pads may be bridged with solder either high or low (or the pins connected to +3.3V / 0V). (My board is supplied with 1, 2 & 4 bridged low and 3 bridged high, i.e. normal latency filter, 44.1kHz de-emphasis disabled, soft-mute not asserted, I2S audio format.)

The normal filter is an FIR with good response, delaying the signal by approx. 500us (at 44.1 kHz) which should be fine. The fast filter is an IIR with slightly poorer response and delays the signal approx. 80us. Very few (if any) audio sources have pre-emphasis applied so DEMP should be low. The XSMT pin would allow muting of the output via a GPI (if the solder bridge was removed). Raspberry Pi supports I2S bitstream so FMT should be low.

*Do not connect pins to a supply rail if the solder bridges are applied.

The VIN pin goes to a pair of voltage regulators, one of which provides the 3.3V required by the PCM510x. This also connects to the A3V3 pin. The regulator is low drop so VIN may be fed from 3.3V or 5V.

The input pins SCK, BCK, DIN & LCK are fed through a resistor pack which should allow 5V signals to be connected to the 3.3V PCM510x chip, i.e. the board is 3.3V but 5V tolerant.

*Note: LCK pin is actually LRCK (left right clock).

The 'L' & 'R' pins are directly connected to the 3.5mm jack. Simultaneous connection to both should be avoided. The 2 'G' pins are connected to ground and are provided for convenience of wiring audio output jacks.

This is a very well designed PCB. It is a shame that this description is not provided elsewhere.

1
  • 1
    Mine didn't work until I soldered the rear pads as you described. Mine came unsoldered. Thanks Commented Sep 18, 2023 at 19:22
2

DAC BOARD > Raspberry Pi ZeroW connector J8

 SCK         > Not wired (Internally generated)
 BCK         > PIN 12    (GPIO18)
 DIN         > PIN 40    (GPIO21)
 LRCK        > PIN 35    (GPIO19)
 GND         > PIN 6     (GND)
 VIN         > PIN 2     (5V)

Pinouts - Credit Kamran Sethi

Driver setup and Mplayer Software install:

For the command line player on an existing system, the setup instructions are here:

https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/

enter image description here

5
  • Link is broken. Here is the new one hifiberry.com/docs/software/configuring-linux-3-18-x
    – jagjordi
    Commented May 8, 2022 at 11:54
  • Link updated. thanks @jagjordi
    – null
    Commented May 9, 2022 at 13:13
  • Which dtoverlay= value did you use? There are several possibilities, not sure which would go with this generic hardware. Thanks! Commented Mar 12 at 23:06
  • (I have tried dtoverlay=hifiberry-dac, which does not seem to work; there are like 9 different possible values, not sure I'm up for trying every one. :-) Commented Mar 12 at 23:15
  • (Sorry to comment-bomb, here!) OK, I had my wiring wrong, and dtoverlay=hifiberry-dac works fine now! This on a PiZeroW and Bullseye. Thanks again! Commented Mar 13 at 0:18
1

Got a highly distorted sound when HDMI cable was unplugged. Sound was good again when I touched a ground connection on RPI. So there is some issue with grounding.
Took me a 3 hour search to find the solution. All works fine when SCK is connected to GND. Hope this helps.

2
  • 1
    I don't know if it is related, but I hooked one up to an ESP32 and it didn't work well until I pull-down the SCK pin to ground
    – Scott Wood
    Commented Dec 18, 2018 at 15:28
  • According to the datasheet, SCK provides a system clock, whisch has to be a multiple of BCK. If SCK is connected to ground, the chip uses a PLL to generate SCK internally.
    – JavaLatte
    Commented Aug 7, 2022 at 10:34
0

This post doesn't add much fundamentally new information, but it does (1) give a step-by-step visual guide, and (2) document the process for an older Pi 1 B with the "P5" header.

Here's how my DAC arrived — notice none of the pads are soldered, unlike most of the pictures you see online.

DAC top, original

DAC bottom, original

As the other answers note, the 3-pad groupings are used to select functionality for the DAC.

Using the labeling on my board, we want:

  • H1L: FLT — "low" for normal latency filter
  • H2L: DEMP — "low" to disable
  • H3L: XSMT — "high" to disable
  • H4L: FMT — "low" for I2S

A later picture will show these.

Aside: For soldering the pads, I found it very useful to "paint" the desired 2 pads with flux. Then, the solder flows nicely onto them and avoids the other unwanted pad. They are pretty small, so it's a little fussy to get right.

Next, here is my Raspberry Pi board, showing the P5 header that we'll use.

Pi top, original

The P5 header is fairly well-documented here: https://www.raspberrypi-spy.co.uk/2012/09/raspberry-pi-p5-header/ There is some more good info in the original announcement from 2012: https://web.archive.org/web/20121021133116/http://www.raspberrypi.org/archives/1929

In particular, they say:

This carries the four GPIO signals [BCM2835/GPIO28 – BCM2835/GPIO31] named GPIO7 – GPIO10 respectively, along with +5V0, +3V3 and two 0V. Currently this connector is not populated.

...

This GPIO allocation provides access to one of:

  • SDA0, SCL0 (Operating independently of P1 SDA1, SCL1); or
  • PCM_CLK, PCM_FS, PCM_DIN, PCM_DOUT or I2S; or
  • Four GPIO signals.

So, for an audio application like this, these are the pin functions:

  • Pin 1: +5V
  • Pin 2: +3.3V
  • Pin 3: GPIO28 / PCM_CLK
  • Pin 4: GPIO29 / PCM_FS
  • Pin 5: GPIO30 / PCM_DIN
  • Pin 6: GPIO31 / PCM_DOUT
  • Pin 7: 0V Ground
  • Pin 8: 0V Ground

We won't use PCM_DIN, since that's for input (eg: a microphone). We also won't use 3.3V or the other Ground; thus we'll use 5 pins total (1,3,4,6,8). Note: as mentioned in other answers, the DAC internally uses 3.3V, but has a voltage regulator so can take 5V as input. So, probably either will work; I used 5V.

Aside: I'm not really sure the difference between PCM_xxx and I2S. On the DAC, we'll set its mode to I2S, but the pinout on the Pi matches PCM_xxx usage. I'm not sure why in the original release notes they said "PCM_xxx ... or I2S". Maybe they mean "also referred to as ..." ?

Confusing terminology:

The pin names are a little sloppy between the DAC and the Pi (and apparently everywhere in electronics, to be fair). If you look at the I2S Wikipedia page, you'll see some "official" names for things, but they're often not used, or even mis-used! More good info at this site: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fi2s.html

So, here's how things line up:

Pi name DAC name Official Name Notes
CLK BCK "continuous serial clock" (SCK). Typically written "bit clock" (BCLK). Despite the official "SCK" designation, this does NOT match the "SCK" pin on the DAC. Ugh.
FS LCK "word select" (WS). Typically called "left-right clock (LRCLK) or "frame sync" (FS)
DOUT DIN "serial data" (SD), but can be called SDATA, SDIN, SDOUT, DACDAT, ADCDAT, etc. We connect the Pi's DOUT to the DAC's DIN. The Pi also has an (unused) DIN. The DAC does not have a DOUT.

Note: we do not use the "SCK" pin on the DAC. As noted in other answers, we solder the pad just next to it, which causes the board to use an internal timer. This corresponds to the optional "master clock" mentioned on Wikipedia — it is not part of the I2S standard. It is sometimes written MCK.

Okay, so with that in mind, lets get wiring.

Note: my Pi had some crud on bottom of the P5 header, which I cleaned off before proceeding. I think it was safe as-is, since the shorted-out part was just the two Ground pins, but just being tidy:

Pi bottom, original, with crud

Not pictured: I soldered pin headers onto the Pi's P5 header and the DAC's 5 pin holes we'll use. Again, flux is your friend.

I used some jewelery pliars to do the crimping of the wire terminals — I don't have the proper tool for that. They worked okay.

Work in progress:

pliars

A decent terminal:

wire terminal

Here it is all hooked up:

wiring, connected

Note the SCK solder blob.

For reference, these are the wire colors corresponding to the pins:

Color DAC pin Pi Pin Meaning
Red VIN 5V +5V power
Black GND Ground 0V Ground
Yellow LCK PCM_FS word select/frame sync clock
Green DIN PCM_DOUT serial data
Yellow+Black BCK PCM_CLK bit clock

And plugged in with power, WiFi, etc (the DAC has a solid red LED when properly powered):

wide shot, all powered on

And then put in a box:

mounted in a box

Note the solder blobs for H1L–H4L. Also: I like hot glue.

And finally put to use!

final installation, all closed up

A little janky, but it works (:


Not shown here: I installed piCorePlayer and configured it to be a headless player for my home's audio. Getting the driver for the WiFi USB dongle was a small chore (documented here: https://forums.slimdevices.com/forum/user-forums/linux-unix/1716902-success-building-wireless-driver-for-picoreplayer-rtl8821cu#post1716902), but it's all working now.

In the future I'll add some GPIO buttons and maybe some LEDs, but this gets it essentially working.

I hope it helps!

Not the answer you're looking for? Browse other questions tagged or ask your own question.