Audio
I am using a Pi-Zero for this project and unfortunately the Zero has no audio output apart from the HDMI out. With this
in mind we need to create an audio out circuit. This will be a mixture of a pre-built amplifier circuit,a handmade audio
output board and a set of speakers.
For the pre-amp, I used an Adafruit Stereo 3.7W Class D Audio Amplifier
The speakers I bouught from Poundland, just a cheap set of speakers designed to plug into a smartphone. Quality is not great,
but we don’t neeed much in the way of audio quality anyway. Dissassemble the unit and rip out the speakers . I would
recommend rewiring them as well as the cheap wires can be a pig to workk with.
Finally, we need to build a simple circuit to get audio from the Pi’s GPIO pins. For this we need the following components:
•
2 x 670 Ohm resistors
•
2 x 0.1 uF Cerramic Capacitors
•
2 x 10u Electrolytic Capacitors
•
2 x 100 Ohm Resistors (Optional)
The circuit diagram looks as follows:
R3 &R4 are optional, they are there for noise reduction and you can get away without them.
I assembled the components on a stripboard with a 9 pin socket to plug the Pre-amp into. The design is as below:
On the left are the connections from the Raspberry Pi. We need 5V power for the Pre-amp as well as GND and the GPIO inputs.
I am using 13 and 19 (pin #33 and pin #35).
Once this is assembled and hooked up we need to makke a minot change to the Pi’s boot config to tell it to use the alternate
pin numebrs for audio output.
Type:
sudo nano /boot/config.txt
Insert the following line at the end fo the file:
dtoverlay=pwm-2chan,pin=19,func=2,pin2=13,func2=4
Hit Ctrl+X to save exit the file.
You might also need to turn the volume up so at the command line type:
alsamixer
and press enter
Use the up arrow key on your keyboard to increase the volume and press Esc to exit.
Once done, reboot your Pi and try playing an audio file.