Raspberry Pi TOSLINK transceiver hat

Optical digital audio I/O for Raspberry Pi

Similar projects worth following
The Raspberry Pi has support for i2s audio I/O. It's fairly simple to add a S/PDIF transceiver chip and optical audio I/O ports on a hat to allow it to be conveniently used.

The WM8804 is the S/PDIF transceiver chip of choice for this project. Adding a single line to the Pi's config.txt file, to wit:


is enough to add support for it.

To be compatible with the driver, the chip needs to be configured in software controlled mode, i2c interfacing, the address has to be 0x3b. This is accomplished with pull-up or pull-down resistors on some of the I/O pins of the WM8804. For the driver, there also needs to be a 27 MHz crystal connected. The i2s I/O pins are connected to the relevant pins on the Pi, and the S/PDIF input and output pins connect to TOSLINK input and output modules.

The result of adding the WM8804 chip to the Pi is that it actually becomes the i2s bus master for clocking purposes. This dramatically improves the i2s timing fidelity, as when the Pi is the i2s clock master it winds up generating a lot of jitter because i2s clock frequencies don't divide evenly from the Pi's master clock source.

Of course, instead of optical I/O, you can add the WM8804 chip for timing and hook the i2s bus up to a high quality i2s DAC, like the PCM1793. Personally, I already have a high quality TOSLINK DAC project, which has the benefit of being totally electrically isolated from the Pi.

Adobe Portable Document Format - 47.84 kB - 11/16/2021 at 20:04


brd - 55.68 kB - 11/16/2021 at 20:02


sch - 139.59 kB - 11/16/2021 at 20:02


  • A required mixer setting

    Nick Sayer11/18/2021 at 06:24 5 comments

    Note that to get the output to work, you have to set the TX source to "AIF" - that is, you have to configure the chip to generate the TX output from the i2s input on the chip. You can do this in amixer by using cset to set the "Tx Source" control to whichever value (probably 1) that decodes to "AIF". The default is "S/PDIF RX", which means that it comes from the receive input, but that will only work if the i2s clocks happen to match up with the S/PDIF received signal.

    If you don't do this, then playing audio won't light up the output receptacle (which means it just won't work).

    You don't need to do this for recording - it always sends the S/PDIF receiver input to the i2s receive pin. But you must insure that the parameters for the reception actually match up with the input source.

View project log

Enjoy this project?



Nick Sayer wrote 05/27/2023 at 03:16 point

To change the optical into coax, there are some circuit suggestions on the WM8804 datasheet (page 63). On the input side, you use a 75Ω resistor across the input to set the impedance, then use a 0.1µF cap in series with pin 20. On the output side, they suggest from pin 17 a voltage divider of 210Ω and 110Ω to ground and from the center of that a 0.1µF cap in series to the output.

  Are you sure? yes | no

Keith Shepherd wrote 04/17/2023 at 15:28 point

This is really awesome!  I had a couple of hopefully quick questions:

1. Is L1 and Inductor or Resistor?  In the schematic it's listed as 400R, but uses the inductor symbol. If it's an inductor, what should the value be?

2. Would it be possible to replace the TOSLINK in/out with Coax digital in / out instead?  Would I need to change the circuits around the PLR135 / PLT133 or simple replace the jacks?

Thank you!

  Are you sure? yes | no

Bart wrote 04/29/2023 at 19:30 point

Look at the actual pictures of the circuit: to me L1 seems same as L2.

It sure doesn't have resistor markings...I'd go with an inductor :)

  Are you sure? yes | no

Nick Sayer wrote 05/27/2023 at 03:12 point

L1 is actually a ferrite bead. Those are inductors, but use ohms as units. Go figure.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates