Error reading PDM mic #1778
-
I cobbled together the code below from the examples and docs. When I run it, I get only this repeated output:
I have an Adafruit PDM Mic connected to an Adafruit Matrix Portal S3 using pins A1 and A3 for clock and data. The WS is hardwired low on this mono microphone. The code generating the error log is size_t readBytes(void *dest, size_t size_bytes) {
size_t result = 0;
if (i2s_channel_read(rx_chan, dest, size_bytes, &result,
ticks_to_wait_read) != ESP_OK) {
TRACEE();
}
return result;
} I'm not sure what the actual error is, of course. Is it disliking the data it sees? Is it a configuration problem? #include "AudioTools.h"
AudioInfo info(44100, 1, 16);
I2SStream i2sStream; // Access I2S as stream
CsvOutput<int16_t> csvStream(Serial);
StreamCopy copier(csvStream, i2sStream); // copy i2sStream to csvStream
const int I2S_SCK = A1;
const int I2S_SD = A3;
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
auto cfg = i2sStream.defaultConfig(RX_MODE);
cfg.copyFrom(info);
cfg.signal_type = PDM;
cfg.i2s_format = I2S_STD_FORMAT; // or try with I2S_LSB_FORMAT
cfg.is_master = true;
// this module nees a master clock if the ESP32 is master
cfg.use_apll = false; // try with yes
cfg.pin_data = I2S_SD;
cfg.pin_mck = I2S_SCK;
i2sStream.begin(cfg);
// make sure that we have the correct channels set up
csvStream.begin(info);
}
// Arduino loop - copy data
void loop() {
copier.copy();
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
If you check your log properly you should see the following "Only TX supported for PDM"! |
Beta Was this translation helpful? Give feedback.
-
Try to activate the ESP32 logging in the Tools menu, this might eventually give another clue. You can change the installed version in the boards manager on the right: Just type ESP32 to narrow down the list and then for the esp32 from Espressif you can select the version to be used. The responsible code can be found in src/AudioTools/CoreAudio/AudioI2S/I2SESP32V1.h. As you can see in the log, the logic on line 379 seems to be failing. What ESP version are you using ? |
Beta Was this translation helpful? Give feedback.
-
The mck is not used for PDM : only pin_data and pin_bck ! Please use proper GPIO numbers as documented in the Wiki. I have updated the Wiki and the example |
Beta Was this translation helpful? Give feedback.
If you check your log properly you should see the following "Only TX supported for PDM"!
I just committed the RX support for PDM: please let me know if this is working....