TRMpcm on Particle Photon (or how to play a WAV)

I am starting a project and evaluating the Photon.
I need to download short audio files from the web and play them from the Photon, on some trigger.
8b at 8Khz should be enough.
What is the easiest way of doing it? Is WAV a good choise? What is the simplest HW way?
And, in Arduino world, the TRMpcm library can solve most of the SW problems. Is there something similar here? or can I use the same library?
Lastly, the STM32F205, according to the datasheet, have some audio capabilities. Are they usable for this?
Thanks a lot,


if you have something similar in Arduinoland, we will be able to help you port stuff over.

@peekay123 is crazy good in porting libraries. :wink:

Looking at the STM32F205 datasheet, i’m guessing you are talking about Inter-integrated sound (I2S) .

They are linked to SPI2 and SPI3 but SPI2 is used for the microUSB port but i looked at the SPI3 pins and they seems to be exposed via the GPIO pins.


This however, would also require firmware changes and i don’t think it will happen any time soon.

Hi @eli, great question!

The STM32F205 audio capabilities are exposed via the standard analogWrite() function. On most pins it does PWM, but it will set real analog voltages on two pins of the Photon: DAC (called DAC1 in code) and A3 (called DAC2 in code). This is documented under analogWrite:

WAV files will be the right choice, since transcoding from something like MP3 can be difficult in firmware.

I just checked on the TMRpcm library—no one has ported it to Particle yet, and the library as is has Atmel-specific code that won’t work on the Photon.

The right way to handle audio in hardware is to have timer interrupts read a buffer and write to the DAC pins on a schedule. If you can use DMA, then even better.

So here are your options as I see them at the moment:

  • Port the TMRpcm library either yourself or with help. If you login to, click the libraries icon on the left, then click the “contribute a library” button, you’ll get an explanation of how this works.
  • Write code to setup the interrupts and write to the DAC pins.
  • Bit bang the DAC pins in loop, checking the time with micros.

@mdma is traveling right now, but he may have more advice here.


1 Like

Thank you @zachary and @kennethlimcp!
I guess the first step will be to order a Photon and get to work.
I will report back (and most probably with follow up questions.)


1 Like

Hi @eli, how did your project go? Where you able to play audio using I2S?

Did you get this to work ?