Pico Audio Pack Support

I may have missed something but I can’t find any libraries or examples for the Raspberry Pi Pico Audio pack.

The product page refers to the Pico SDK but, other than bit banging the audio into the card using DMA or manually toggling the GPIO pins I can’t see any higher level support.

Have I missed something or am I going to have to start reading up on the DMA, timer and interrupt functions and roll my own driver?

1 Like

The software end of things for the Pico accessories seems a bit underbaked at the moment, I think some boards have hit the shop before the accompanying code is finished. It might be worth poking @Gadgetoid on twitter or Github to see what the deal is, the repo page says that the audio pack has a library, so he may have just forgotten to unhide it?

1 Like

https://www.raspberrypi.org/products/raspberry-pi-pico/specifications/ says that the chip comes with two I2S peripherals but can’t find any examples either at https://github.com/pimoroni/pimoroni-pico or https://github.com/raspberrypi/pico-examples

In the 2040 Datasheet there is mention of a “popcorn” media player that uses the I2S but I can’t find any other details of this.

https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython says:

You’ll note there’s no I2S peripheral… instead of having specific hardware support for serial-data-like peripherals like these, the RP2040 comes with the PIO state machine system which is a … way to create custom hardware logic and data processing blocks. … … … often we bitbang the timing-specific protocol… for the RP2040, we instead use a PIO object that reads in the data buffer and clocks out the right bitstream… Same with I2S audio in or out.

But the lack of I2S does seem to contradict https://www.raspberrypi.org/products/raspberry-pi-pico/specifications/

And there still doesn’t seem to be any example of how to get PIO to do I2S anyway.

But there is something to at least make a start on PIO here: https://github.com/raspberrypi/pico-examples/tree/master/pio

In the “readme” for the SDK, it mentions:

Additional libraries/APIs that are not yet ready for inclusion in the Pico SDK can be found in https://github.com/raspberrypi/pico-extras

And, sure enough, here’s:

Still no examples… but there’s some library source to get started.

But the lack of I2S does seem to contradict https://www.raspberrypi.org/products/raspberry-pi-pico/specifications/

That says I2C, which is not the same as I2S. The RP2040 doesn’t have I2S hardware units, but it’s possible to emulate one using the Programmable IO, which is what your later links are describing.

1 Like

Has anyone had any luck getting the i2s example from pico-extras working with the pico-audio?
It certainly isn’t working for me.

Edit: Ok I managed to get a very glitchy looking sinewave out of one of the outs using the example.
Appears the API expects you to set the GPIO number not the pin number, so its really:


The web page for the device on the pimoroni store incorrectly tells you to set them to 12 and 14 respectively.
Now to figure out how to get stereo out before making an i2S API for humans.


as promised on the product page:
Please note that Pico Audio Pack only currently works with the C/C++ Pico SDK! We have Micro Python support planned but it is not available yet.
Any idea when this will happen?
As a newbie to pico, and python, (and so much more) a BUMP from the heart…

Now to figure out how to get stereo out before making an i2S API for humans.

any luck with doing that yet?

Sorry Mike not yet, been dead super busy at work and i’ve not had the mental bandwidth to get round to making a friendlier lib. Defo near the top of my todo list tho!

Did a quick port of the I2S “sine wave” example from Pico Playground into our repository here: Add Pico Audio Pack example for #36 by Gadgetoid · Pull Request #113 · pimoroni/pimoroni-pico · GitHub

It still requires Pico Extras, though - GitHub - raspberrypi/pico-extras

MicroPython support depends on MicroPython upstream adding some support for i2s audio, which is still very much in the taking-shape phase: https://github.com/micropython/micropython/pull/4471 (note, the linked discussion is not about Pico, but its conclusion will set the precedent that Pico MicroPython i2s support should try and follow)

It would appear that CircuitPython already supports i2s audio on the Pico - Playing sounds from the Raspberry Pi Pico using CircuitPython - a journey of discovery - Raspberry Pi Pod and micro:bit base

Sorry I might be being a bit thick here but I can not find a file that mentions I2S in the pimoroni-pico-main download.

It’s here - pimoroni-pico/examples/pico_audio at main · pimoroni/pimoroni-pico · GitHub

Thanks it is there now.
I kept a copy of what I downloaded after your first announcement above and it wasn’t in it. Maybe it took GitHub a bit of time to serve up the new one. Off to try it, looks a step up from the Raspberry Pi one.

Sorry to be so thick again but I can’t get your code to compile. I copied the pico_audio project and ran a cmake …
pi@raspberrypi400:~/pico_audio/build $ cmake … -DPICO_SDK_POST_LIST_DIRS=/home/pi/pico/pico-extras
I got a warning saying
“No cmake_minimum_required command is present”
and another one saying
" Manually-specified variables were not used by the project:
Then a make commend instead of compiling did nothing.
So I must be missing a step any idea what it is?

I used an other (modified) cmake file that I had used to run the sine_wave program from the pico-playground. This compiled everything but fell over when it came to linking the modules.

tnx to @gadgetoid for the clarifications and the link to ‘pico_audio’. I discovered I had that example in an installed clone of the pimoroni-pico repository. After adding to settings.json in VSCode:
“cmake.configureSettings”: {
“PICO_SDK_POST_LIST_DIRS”: ["${ENV:PICO_DRV}/pico/pico-extras", “…some other path…”] },
I was able to successfully build and flash the pico_audio example to a RPi Pico with back-to-back connected the pico-audio pack. It made the audio working on both a little speaker and on a set of headphones for a mobile phone. Audio worked on either ‘phones’ or ‘line out’.

Btw: ${ENV:PICO_SDK_PATH} and ${ENV:PICO_DRV} are environment variables that I defined in (~/.bashrc) of a MS Windows 10 WSL1/Ubuntu 20.04 session.