A couple of years ago I bought an Adafruit I2S 3W Stereo Speaker Bonnet for my Raspberry Pi from Pimoroni here in the UK. It’s only recently that I’ve been able to take it out of it’s packaging and give it a try.
One of the great things about Adafruit are their really clear tutorials that they have for their products and the speaker bonnet is no exception.
It looks like there have been some design changes since Adafruit released the product as I didn’t, as the tutorial explained, have to solder the header onto the board – there was a surface mount header already fitted on the underside. I did solder the two 3.5mm terminal blocks though as I didn’t have a JST plug.
It’s when I came to setup the Raspberry Pi that I ran into problems…
Adafruit’s tutorial asks you to run a Bash script when the Raspberry Pi is conencted to the internet:
curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash
Running the script twice with a restart in between, as asked, I was hopeful that I could get some sounds out of my speakers but unfortunately there was nothing.
I did hear some crackling and popping noises when the Raspberry Pi restarted but I put this down to the I2S interface powering ON and OFF.
Adafruit provide the schematics for their products so I could go in and see what chip it was using and in this case it was the MAX98357A.
Name: max98357a Info: Configures the Maxim MAX98357A I2S DAC Load: dtoverlay=max98357a,<param>=<val> Params: no-sdmode Driver does not manage the state of the DAC's SD_MODE pin (i.e. chip is always on). sdmode-pin integer, GPIO pin connected to the SD_MODE input of the DAC (default GPIO4 if parameter omitted).
So it looks like the device has been added to later Raspberry Pi OS builds which makes things much simpler. The Adafruit tutorial was last updated in 2016, as I write this, so the changes would have been made since then.
The next thing to figure out is what parameters to use and to do that we need to go back to the schematics.
A closer look shows that the the SD_MODE pin of the MAX98357A on both the left and right channels is permanently tied to the 5V rail. On the right hand channel you will also notice a series resistor here but this is only to let the chip know that it is to extract and amplify the right channel data, without this it uses the left channel. The datasheet covers this in great detail.
The SD_MODE pin is not controlled by the a GPIO so we can now set the value for the parameter in the overlay.
To get everything working all you need to do is edit the
config.txt file and add the following line:
If you did this from within Pi OS then carry out a reboot and once everything has restarted you should be able to select the MAX98357A as your audio output device.
Hope you found this post useful. Happy listening.