How can I get the recorded data from MEMS mic?

Device: RAK18032 + RAK11200 + RAK19007

I need to use 18032 to record ultrasonic sounds. The microphone produces PDM data and how can I analyse (and save) it in Serial Port (maybe using Python) (-> convert it to .wav for playing)
Also, I am curious about the sampling rate of PDM. In the example of RecordToSD, the data_size is defined as frequency * BIT_PER_SAMPLE * duration / 8. I use part of the code and print buf to the serial. But it does not run duration(s). I am curious about the meaning of frequency and BIT_PER_SAMPLE.
Furthermore, may I know if I can use I2S to get the data of microphone and how can I do it.

If you want to pass the data over the serial port you will need to save the PDM data internally (or to the SD card) before sending it over the serial port. The reason is that the Serial Port is not going to be fast enough to send the data from the ultrasonic microphone.
For sending the data you can look at the PDMSerialPlotter examples as it sens data over the Serial Port.
BIT_PER_SAMPLE is the number of bits used for each sample of audio. In standard audio this would be 8,16,24 or 32 bits. (16 is the most common)
If you take the samples and put them back to back in a file and put the correct header on the file for WAV it will work for you. If you are using python you can look at the wave library for saving the samples (it will put the header on for you then).

If you want I2S data, you would need to accept the data on the RAK11200, then have it send it back out as I2S.

1 Like

Thanks for your reply. If I directly use I2S on RAK11200, do I need to use a SD card. In other word, do I necessarily need to purchase a 18003 (microSD) to save the data?

We haven’t tested taking the data from PDM and directly sending it out over I2S, however it should work. So I don’t expect you’ll need the RAK18003 (or SD card).
(Please be aware of the data rates, especially if using the ultrasonic microphone where you want higher rates).
Out of curiosity, what is the application you are building?

Well. We are working on a sensing project which requires the speaker transmit a signal and mic receive the signal. The ultrasonic speaker is the rak18032. I additionally purchased an PUI ultrasonic speaker and an amplifier, hopefully can be connected to our block. The pipeline would be I control the DAC pins (if any) to broadcast the signals and then call the mic to receive the sequences. Any suggestions for building this system? Thanks!

Sounds like an interesting project. I don’t have any specific suggestions, but let me know how it goes.