Variable PDM Microphone Sample Rates on nRF52840 Sense

Hey everyone!

I’ve been using the PDM microphone on the XIAO nRF52840 sense to record audio data. It samples data at a rate of 16 kHz meaning it can process frequencies up to around 8 kHz (has two readings on each wave). My firmware fills an integer buffer of length 32,767 with PCM data, then writes it out to an SD card.

My audio recording application only needs to capture frequencies from 0 kHz up to 2 kHz - 4 kHz. Is it possible to reduce the 16 kHz sample frequency to 4 kHz - 8 kHz to increase time between SD writes to conserve battery life? In my testing, I can change PDM_SAMPLE_RATE to be different from 16000, but it doesn’t record any audio data.

if (!PDM.begin(1, PDM_SAMPLE_RATE)) {     // mono 16000 samples/sec
    Serial.println("Failed to start PDM!");
  }

PDM Library

Thanks in advance!

Hi cam,

See PDM.cpp starting at line 86. Only 16000 and 41667 sample rates are supported.
For example, if you want to sample at 8 kHz, set the sample rate to 16 kHz and record the data to the SD card every two times, you will have sampled at 8 kHz.

I measured the average current per minute.
It was 17 mA at 16 kHz, 14 mA at 8 kHz, and 10 mA with the on-chip DCDC converter enabled.

To enable DCDC, add the following line to setup()

NRF_POWER->DCDCEN = 1; // enable on chip DCDC converter

Do you mean to disregard every other reading?

Please see line 70 of the attached file.
POST_nRF52_XIAO_PDM_SD_8kHz.zip (1.4 KB)

Do you mean to disregard every other reading?

What do you mean by “every other reading”?