update 04/04/23 : note that due to an update of PI OS only the 64bits version on the PI OS is working.
GitHub - Sybility/WM8960-Audio-HAT: The drivers of [WM8960 Audio HAT] for Raspberry Pi
Installation:
I have not written the install script but it will be fully compatible with this project form WAVESHARE as it is based on the WOLFSON WM8960. The Raspiaudio implementation offers an additional external microphone input as well as stereo speakers onboard.
Choose your method :
Method 1 the simple way: if you just need to use the speakers and onboard microphone:
UPDATE 21/04/22
Method 2 full control if you just need to use all options (longer installation):
[update 17/01/23] there is a bug in the installation script, while you are fixing it you can use this script as it is compatible :
[updated 25/04/22]
This is a new method from Seed. Clone the driver and install it with commands copy and paste each line in a terminal window:
git clone GitHub - RASPIAUDIO/WM8960-Audio-HAT: The drivers of [WM8960 Audio HAT] for Raspberry Pi
cd WM8960-Audio-HAT
sudo ./install.sh
sudo reboot
it could take a long time 5 minutes on a PI4, but 15mn or more on a Pi zero, so relax go get a coffee then
sudo reboot
if you use raspbian desktop select the audio device from the top right menu by doing a right click:
To test type
speaker-test -l5 -c2 -t wav
if it does not work redo the install one more time
cd WM8960-Audio-HAT
sudo ./uninstall.sh
sudo ./install.sh
If it does work, just go on youtube and play some music!
Pinout:
GPIO | PIN | FUNCTION |
GPIO2 | PIN3 | I2C SDA |
GPIO3 | PIN5 | I2C SCL |
GPIO25 | PIN22 | LED |
PIN17 | 3.3v | |
PIN25 39 6 14 | GND | |
GPIO19 | PIN35 | I2S LRCLK |
PIN2 4 | 5v | |
GPIO18 | PIN12 | I2S CLK |
GPIO20 | PIN38 | I2S ADC |
GPIO21 | PIN40 | I2S DAC |
GPIO23 | PIN16 | BUTTON (this pin as an external pull up) |
Device number
this will be usefull in the alsa mixer to understand what input is connected to which microphones
Onbard microphones:
Linput1
Rinput1
External microphone jack input:
Linput2
Rinput2
Line input
Linput3
Rinput3
External speakers/speaker output:
SPK_L
SPK_R
Presets
You will notice that alsamixer have a LOT of settings with that dac so it could be confusing at first to do what you want. So I made a few basic scripts to select different devices, these Alasa presets are here : GitHub - RASPIAUDIO/WM8960-Audio-HAT: The drivers of [WM8960 Audio HAT] for Raspberry Pi look for the preset_* files
For example download this Onboard microphones input and headphones output:
For example to only enable the headphones and onboard speakers :
alsactl --file preset_onboard_microphones_input1 restore 0
sudo arecord -f cd -Dhw:0
Here are others scripts I have made:
External microphone input and headphones output:
preset_external_jack_microphone_input2
Onboard microphones input and headphones output:
preset_onboard_microphones_input1
Onboard microphones with high gain input and headphones output:
preset_onboard_microphones_input1_alotofgain
Headphones output:
preset_headphone_jack_output_only
External line input and headphones output:
preset_lineIN-jack_input3
Headphones ans speakers output:
preset_onboard_Speakers_and_headphone_jack_output
To save your own preset:
alsactl --file Mycustom_presets store
To restore your own preset:
alsactl --file Mycustom_presets restore