How Microphone Data from Arduino Nano RP2040 Connect Is Collected

I’m working on receiving data from the onboard PDM microphone on an Arduino Nano RP2040 Connect. Through the Edge Impulse interface, I can record sound data and listen to it, as it’s automatically converted to a .wav file when recorded. However, I want to do this with my own PDM microphone as well, and I can’t figure out how to get useful data and convert it into audio. I’m trying to do this with the onboard mic too, and that hasn’t worked either. I receive a list of amplitude values, but I don’t think it’s able to transmit samples quickly enough to match the 16 kHz frequency. Is there a way to receive this audio data and format it so it can be heard? Thanks so much!

Hello @nroede

However, I want to do this with my own PDM microphone as well, and I can’t figure out how to get useful data and convert it into audio

So, we actually convert the raw data in the studio servers to provide .wav files.

Is there a way to receive this audio data and format it so it can be heard?

You can actually sample it at 8kHz, that way you would be able to transmit it using the data-forwarder.
See the ingestion sketches examples for the Nicla Vision: Arduino Nicla Vision - Edge Impulse Documentation

Where the downsampling is actually pretty simple (just take every other sample):

void onPDMdata() {
  // Query the number of available bytes
  int bytesAvailable = PDM.available();

  // Read into the sample buffer
  PDM.read(sampleBuffer, bytesAvailable);

  // 16-bit, 2 bytes per sample
  samplesRead = bytesAvailable / 2;
}

I hope that helps,

Best,

Louis

1 Like

Ok, that makes sense, thank you so much! I tested that with the onboard microphone and it works perfectly, but unfortunately I’m having issues changing the PDM library to use my own microphone. I modified pins_arduino.h to set:

#define PIN_PDM_CLK	 (1ul)
#define PIN_PDM_DIN	 (9u)

In order to use the TX pin as the clock, and D9 as the data pin instead of the normal 23 and 22 that they’re set to. However, when I rerun the script, it’s just outputting an initial arbitrary curve for the first few milliseconds, then values of zero for the rest. I do know this microphone works, as I’ve been able to test it in this configuration but not get the data out in a useful form. Do you know how this could be fixed/how to modify the PDM library to work with a non-default mic? Thanks so much again!

Hello @nroede,

Which microphone are you using?

Best,

Louis

1 Like

Hi @louis -
I’m using the Vesper VM3000, and have still been having issues. Thanks again for the help! Do you know how I could proceed?

Hi @nroede,

I have never used this microphone and tried to look online for an arduino integration but there is not much resources available.
Maybe someone from the community can help here?
In the meantime, if you find a solution, do not hesitate to post it here, I’m sure it will help other members in the future.

Best,

Louis