Sound output on PyPortal Titano with Circuitpython


I’m trying to make sound output work properly on a bunch of PyPortal Titano boards.
I have a small loudspeaker directly coupled to the sound output and use the blocking version of play_file from Circuitpython, eg.

pyportal.play_file(“myfile.wav", wait_to_finish=True)

The sounds is absolutely terrible.

Sometimes it is randomly fine for a short while but in general it is very scratchy and distorted beyond recognition (however, not choppy). This seems to get a lot worse when there are background tasks active (eg. display update) which overlays further spiky static noise on the signal. I have tried this with several boards and the behaviour is consistent.

Some other user who had similar problem on an RPI posted an example here: Raspberry Pi Pico - No I2S pins, No PIO, so why does this work? - YouTube
My sound is similar in type but much worse.

I have two questions:

(1) Is there some other software trick to play back files that may produce better results.
(2) If this cannot be fixed in software, what do you recommend as additional audio hardware to improve this. The main constraint is size, so I would need a small module… Would this be the best choice to combine with a PyPortal: ?



Hey Berndm,

Welcome to the forum!!

Unfortunately, I don’t think there will be any tricks that you’ll be able to do in software, the main processor on the PyPortal is an ATSAMD51J20A, which features a single-core so any tasks will be blocking and audio especially requiring a relatively high amount of resources to process and output the audio(while also trying to run the screen streaming audio would be extremely difficult).
The 12-bit DAC onboard is great for running some tones and maybe some basic music but not perfect audio like a commercial phone or speaker.

While the PyPortal is an amazing product it doesnt break out a massive amount of IO to work with (not needed in most instances) but would be handy if Serial was available which is what the module linked uses.
I found this module here that would be perfect for the application (No stock at Core at the moment unfortuntately):
Or a setup with an IO expander to trigger some trigger pins on another MP3 playback board

This setup will require the IO expander to drive the pins low to activate the audio tracks.

That’s quite an interesting setup on the Pico, I’m not certain if it’s able to source the power through the Pico’s power pins (the MAX98357 says it can need up to 3.2W, depending on the USB protocol used it might not be able to source that. Shouldn’t be an issue for the PyPortal though!

Let us know if you have any other questions!

1 Like

Hi Liam,

thanks a lot for your help and the links to these modules. They seem to be interesting choices.
I notice that you have NOT recommended the DFplayer mini
which I originally thought might be a good choice (and of which there is stock).
For which reasons would you prefer the SparkFun Qwiic MP3 Trigger over this?




Hey Berndm,

I would imagine Liam chose that one since the PyPortal doesnt have any UART pins available for use (which is what the mini MP3 player uses). You could dive into using the analog output to control it but might be a deep rabbit hole to explore.


Hi Liam,

that makes a lot of sense for the full functionality. But according to the DF Robot Wiki linked on your pages I would have thought that I can also use it in “simple mode” just by driving the ADKEY inputs of the module with AD outputs of the PyPortal (D3/D4). Am I wrong in that regard?



Hey Berndm,

Good catch there! PS: Those with the shield next to their names are members of the Core staff.
PPS: I could be overlooking something here and there be a much simpler way to get better quality audio out of the PyPortal.

I found a reference to the intended part to be hooked up with the ADKEY pins:
It looks like this is intended to be hooked up like a voltage divider based on the connection diagram on the Wiki page there would be an internal pull up resistor, pressing each button would bring the actual ADKEY pin to a different voltage, a work around could be to unsolder the pin and use an output from the DAC (It looks like its broken out on pin D3 as you mentioned, but not D4, as thats an analog input) this method might create some unexpected results.

A digital potentiometer might be a go-er, to get similar results!

Awesome Idea’s, it might even be worth grabbing one and having a play around with it. A similar analog to the PyPortal would probably be the Pico for experimenting (great all round board as well).


I think you’re right, Liam - might have to grab some and have a play with them (and fry some :slight_smile: )
I think I’ll do that (and maybe the Spark board you recommended when it comes back in). In the meantime, I just downloaded the latest CircuitPython 7 alpha release and the audio seems to have improved a lot! So far only tried with the built-in speaker but I don’t think that should make a difference.

So you’re not core staff if I understood your note correctly. Well, thanks even more for all your help. Much appreciated!