Audio Processing with RAK3112

  • What product do you wish to discuss? RAK3112

  • What firmware are you using? Arduino BSP

  • Computer OS? MacOS ver 13.7

  • How often does the problem happen?
    Always. I can’t get it to compile using the RAKwireless-Audio libraries

  • How can we replicate the problem?
    I updated the libraries for the official ESP32 boards to select the RAK3112 board. When I try to compile with the Arduino IDE 1.8, I get an error saying it can’t find the “PDM.h” library.

I can compile if I select the WisCore RAK11200 board.

  • Provide source code if custom firmware is used or link to example if RAKwireless example code is used.

Example Code:

#include “audio.h”
int channels = 1; //1 mono 2 stereo
// default PCM output frequency
static const int frequency = 16000;

// buffer to read samples into, each sample is 16-bits
short sampleBuffer[BUFFER_SIZE];

void setup() {

pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
delay(500);
pinMode(LED_GREEN, OUTPUT);
digitalWrite(LED_GREEN, HIGH);

// Initialize Serial for debug output
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 3000)
{
delay(100);
}
else
{
break;
}
}

// initialize PDM with:
// - one channel (mono mode)
// - a 16 kHz sample rate
// default PCM output frequency
if (!PDM.begin(channels, frequency)) {
Serial.println(“Failed to start PDM!”);
while (1) yield();
}

Serial.println(“=====================================”);
Serial.println(“PDM test”);
Serial.println(“=====================================”);

pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, HIGH);
}

void loop() {

// Read data from microphone
int sampleRead = PDM.read(sampleBuffer, sizeof(sampleBuffer));

sampleRead = sampleRead / 2; //Each short data contains two Bytes
// wait for samples to be read
if (sampleRead > 0) {
// print samples to the serial monitor or plotter
for (int i = 0; i < sampleRead; i++) {
if (channels == 2)
{
Serial.print(“L:”);
Serial.print(sampleBuffer[i]);
Serial.print(" R:");
i++;
}
Serial.println(sampleBuffer[i]);
}
sampleRead = 0;
}
}

Error received:

In file included from /Users/rmunizr/Documents/Arduino/libraries/RAKwireless-Audio-library-main/examples/RAK11200/PDMSerialPlotter/PDMSerialPlotter.ino:13:
/Users/rmunizr/Documents/Arduino/libraries/RAKwireless-Audio-library-main/src/audio.h:7:10: fatal error: PDM.h: No such file or directory
7 | #include <PDM.h>
| ^~~~~~~
compilation terminated.
exit status 1
Error compilando para la tarjeta RAKwireless RAK3112.

I’m working on developing an audio analyzer for industrial applications using FFT, DSP, and various microphones. I decided to use the ESP32 S3 for its Edge AI capabilities, but now I see that I can’t use Rak Wireless’ official audio libraries for that SoC.

Any help to continue development?

Hi,

The currently released RAK wireless audio libraries unfortunately do not support the RAK3112. We are working on updating them to support the RAK3112 - let me check on when we expect to have them ready and get back to you.