Sampling failed : Timeout - on changing sampling frequency

I wanted to sample Arduino Nano 33 sense board at 4kHz instead of 16kHz.

  1. I changed the value in ei_microphone.cpp from 4000 to 16000 in line 36
    AUDIO_SAMPLING_FREQUENCY 16000

  2. And also changed the values in file - /src/ingestion-sdk-platform/nano-ble33/ei_device_nano_ble33.cpp
    from 16000 to 4000 in these two lines -
    sensors[MICROPHONE].max_sample_length_s = available_bytes / (16000 * 2);
    sensors[MICROPHONE].frequencies[0] = 16000.0f;

On starting sampling, the row hangs on “Sampling… (1s left)” and the error is-
Sampling failed : Timeout when waiting for > (timeout: 4000) AT+SAMPLESTART = Built-in microphone

Should I change any other values in the firmware before building it?

Hi @dhruvilodhavia, after doing some research, I am not sure if it is possible. I experienced the same thing as you and found this: https://github.com/arduino/ArduinoCore-nRF528x-mbedos/blob/master/libraries/PDM/src/PDM.cpp, which seems to suggest that the sampling rate is limited. Doing some other web searches I did not find a solution for attempting to sample at 4kHz. This appears to be related to the PDM driver.

Hi @dhruvilodhavia,

Down sampling will be supported for targets using a Nordic processor somewhere this week.
This includes the Arduino Nano 33 BLE Sense board. Default frequencies will be 16kHz, 8KHz and 4KHz.

I’ll let you know when this feature is live.

Thank you for the reply @Arjan, is the feature live now?

Hi @dhruvilodhavia,

Completely forget to notify you, but the audio downsampling feature is indeed live now for the Arduino Nano 33 BLE Sense.

Regards,
Arjan

Hi, @Arjan. Thank you.
I looked through the changes in the code and flashed my code with the current version. There were no options given on edge impulse website to change the sampling frequency while collecting the data so I assume we need to change the code to do it.
In the ei_microphone.cpp file, I changed
static uint32_t audio_sampling_frequency = 16000 ->
static uint32_t audio_sampling_frequency = 8000
I also made changes in ei_device_nano_ble33.cpp file
sensors[MICROPHONE].max_sample_length_s = available_bytes / (16000 * 2); ->
sensors[MICROPHONE].max_sample_length_s = available_bytes / (8000 * 2);
Still I the microphone did not sample at 8000Hz. I request you to let me know what changes I need to make in the code to downsample the audio.

Did you grab the code from https://github.com/edgeimpulse/firmware-arduino-nano-33-ble-sense ? I just tested it and for me it works. Can you also try to refresh the web page? Maybe the new settings are not loaded in correctly.

1 Like

Thank you! Yes I was able to do it now. I was previously using the already built firmware linked on the edge impulse nano 33 ble sense docs page.

1 Like