To purchase a completed board or to get a BOM so you can make your own, visit the store page here.
A few methods are available to get audio from the Pi Zero. The easiest is just to use an HDMI display, but that’s not always an option. The next option is to use a USB audio adapter. That works fine, but takes up the only available USB port unless you have room in your project for a microUSB hub. There is a third option. This guide explains the the process of getting PWM audio working.
As for software, all that’s required is that you add one line of code to the bottom of your config.txt file on your SD card:
The schematic shows the audio filter circuit that was part of the original Pi. A better one is included in the newer Pi’s, but this will do the job. For this guide a few changes will be made because the Pi Zero’s PWM output is not powerful enough to be audible once the filter is installed.
The complete circuit is shown below. It begins with the PWM audio coming from GPIO pins 13 and 18.
From the GPIO we get to the first filter, the High Pass Filter. This one handles the filtering out of low frequencies and allows high frequencies to pass. It consists of a 10nF Tantalum Capacitor connected in line, followed by a 150 Ohm Resistor connected to ground. These low frequencies are now filtered out before reaching the amplifier. A standalone High Pass Filter is shown below for better understanding.
From the output of the amplifier we have the the second half of the circuit, the Low Pass Filter which filters out high frequencies and allows low frequencies to pass. It consists of a 270 Ohm Resistor connected in line, followed by a 33nF Capacitor connected to ground. The filter is placed on the output of the amplifier because it serves a dual purpose. When at full volume and when no audio is playing, the PWM has a constant hiss. Placing the filter on the output of the amplifier drops the volume down to a level where the hiss is barely audible. The volume is still sufficient as long as the OS volume is set at 100%. A standalone Low Pass Filter is shown below for better understanding.
The yellow L and R pads on the amplifier are the positive left and right PWM audio inputs coming from the GPIO and the High Pass Filter. Between them is a shared ground input, which can be any of the grounds on the Pi. For this reason, it makes sense just to connect it directly to the power input ground on the bottom left that’s used to power the audio amplifier. The red pad is the 5v power input, which should come directly from the Pi’s power supply and not the 5v GPIO pin. This little guy can pull a few watts and easily overwhelm the Pi if connected to the GPIO. The pink pads on the right are the audio output leading to the Low Pass Filter and finally to the speakers.
The negative speaker outputs are not used. The speakers and the filter connect directly to the same ground that’s used for power input. This is done so the speakers share a ground, which makes volume control and muting easier. If you don’t need this ability, then the speaker output grounds on the amplifier do work just fine. Just don’t connect them together.
Questions? Comments? Leave a reply.