This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
# Stream PDM Input to CSV Output
## General Description:
To use a PDM microphone you need to have a microcontroller that supports PDM input or a dedicated library.
The ESP32 supports PDM via the I2S API: We stream the sound input from a PDM microphone (PDM Digital MEMS MP34DT01) which we read in from the I2S interface and displays it on the Arduino Serial Plotter.
## Pins
![i2s-adc](https://pschatzmann.github.io/Resources/img/pdm-mic.jpg)
| i2s-mic | ESP32
| ---------| ---------------
| 3V | 3V
| GND | GND
| SEL | GND (GND or 3.3V)
| CLK | WS (GPIO15)
| DAT | IN (GPIO32)
| - | BCK (GPIO14)
## Additional Comments
You can select if you receive only data on the left or right by setting SEL to high or low.
Please note that in the 2.x realease of the Arduino ESP core, the WS pin is used as CLK. Prior to this it was BCK

View File

@@ -0,0 +1,39 @@
/**
* @file streams-i2s_pdm-serial.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-i2s_pdm-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
AudioInfo info(44100, 1, 16);
I2SStream i2sStream; // Access I2S as stream
CsvOutput<int16_t> csvOutput(Serial);
StreamCopy copier(csvOutput, i2sStream); // copy i2sStream to csvOutput
// 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.use_apll = false;
//cfg.auto_clear = false;
cfg.pin_bck = -1; // not used depending on ESP32 core version
i2sStream.begin(cfg);
// make sure that we have the correct channels set up
csvOutput.begin(info);
}
// Arduino loop - copy data
void loop() {
copier.copy();
}