(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example is going to show how to use the PDM TX and RX mode.
## How to Use Example
### Hardware Required
#### General
* A development board with any one of ESP32, ESP32-C3 or ESP32-S3 SoC
* A USB cable for power supply and programming
#### PDM RX
* A PDM microphone whose `sel` pin is supposed to be pulled down, and connecting its `clk` pin to `GPIO_NUM_4`, `data` pin to `GPIO_NUM_5`.
```
┌─────────────┐ ┌──────────────────┐
│ ESP │ │ PDM microphone │
│ │ PDM clock │ │
│ GPIO 0 ├──────────────►│ CLK │
│ │ PDM data │ │
│ GPIO 2 │◄──────────────┤ DATA │
│ │ │ │
│ │ ┌─────┤ SEL │
│ │ │ │ │
│ GND ├─────────┴─────┤ GND │
│ │ │ │
│ VCC ├───────────────┤ VCC │
└─────────────┘ └──────────────────┘
```
#### PDM TX
* An earphone or a speaker
* An audio power amplifier that can input PDM signal. If the power amplifier can only receive the analog signal without PDM clock, a band-pass filter is required to restore the PDM data wave into analog signal, before it is transmitted to the power amplifier.
PDM can only works in simplex mode, setting the macro `EXAMPLE_PDM_DIR` to `EXAMPLE_PDM_TX` or `EXAMPLE_PDM_RX` can choose the PDM direction of this example. But currently ESP32-C3 does not support PDM RX mode.
### Build and Flash
Build the project and flash it to the board, then run monitor tool to view serial output:
```
idf.py -p PORT build flash monitor
```
(To exit the serial monitor, type ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
## Example Output
### PDM TX
While `EXAMPLE_PDM_DIR` is set to `EXAMPLE_PDM_TX`, then you can see the following log:
```
I2S PDM TX example start
---------------------------
D (284) i2s_common: tx channel is registered on I2S0 successfully