tech

info

An I2S (Interactive Two-Way Serial) interface is a type of serial communication protocol used for transferring data between devices.

It is commonly used in computer networking, as well as in audio processing and digital electronics.

I2S interfaces typically use a combination of fast and slow data transfer rates to make efficient use of communication bandwidth and minimize noise and errors.

One of the key features of I2S interfaces is their ability to support full-duplex communication, which allows for the simultaneous transfer of data in both directions.

This makes I2S a popular choice for high-speed data transfer applications.

1. Pin Mapping Logic

To get this working, you simply need to map your microphone's pins to the ESP32’s I2S peripheral. Here is how they correspond:

Microphone Label I2S Standard Name variants ESP32 Function Role
CLK (or BCLK) SCK (Bit Clock) CLK Output The heartbeat that times every individual bit.
L/R (or WS) WS (Word Select) FS Output Toggles to define the start of Left/Right frames.
DATA (or SD) SDIN (Data In) TX Input The digital audio stream entering the ESP32.

2. Why "MCLK" is Missing

If you are looking at ESP32 documentation, you might see a fourth signal called MCLK (Master Clock).

  • The Good News: Most I2S MEMS microphones (like the INMP441 or SPH0645) do not require an MCLK signal. They derive their internal timing directly from the Bit Clock (CLK).
  • The Setup: You can simply leave the MCLK configuration in your code as "unused" or -1.

WS pin

The WS pin stands for Word Select. In the I2S (Inter-IC Sound) protocol, it is the signal that manages the timing and "addressing" of the audio data bits.

Think of it as the toggle switch that tells the receiver (like your ESP32) whether the data currently arriving belongs to the Left channel or the Right channel.

That is correct. The WS pin (Word Select) is absolutely mandatory for I2S communication. You cannot skip it, leave it floating, or tie it directly to a constant voltage (GND/3.3V).

If you skip the WS pin, the ESP32 will have no way of knowing:

When a "word" (an audio sample) starts. Without a sync signal, the data just looks like a random, infinite string of bits.

Which bit is the Most Significant Bit (MSB). Audio data is usually 16, 24, or 32 bits long. WS tells the ESP32 to "start counting" bits for a new sample.

Other Common Names for WS

Depending on the datasheet for your microphone or DAC, you might see the WS pin labeled as:

  • LRCLK (Left/Right Clock)
  • FS (Frame Sync)
  • LRCK

chips and chips

PCM512x 2-VRMS DirectPath™ , 112-dB and 106-dB Audio Stereo DACs With 32-Bit, 384-kHz PCM Interface

Other combine use with ESP32-S3

pins I2S and PDM

  • I2S (Inter-IC Sound): Uses a 3-wire bus (Bit Clock, Word Select/Left-Right Clock, and Data). It transmits pulse-code modulation (PCM) data.
  • PDM (Pulse Density Modulation): Uses a 2-wire bus (Clock and Data). It transmits a high-frequency stream of single bits where the "density" of the bits represents the amplitude.

The ESP32-S3 has two independent I2S peripherals (I2S0 and I2S1). This allows you to use one for output and one for input.

Recommended Wiring Strategy:

To save pins, you can sometimes share the Clock pin, but it is technically difficult because PDM and I2S usually require different clock frequencies. It is much safer to use dedicated pins for each:

Component Signal Suggested ESP32-S3 GPIO
I2S Speaker (e.g., MAX98357A) BCLK (Bit Clock) GPIO 14
LRCK (Word Select) GPIO 15
DIN (Data In) GPIO 16
PDM Mic (e.g., SPM1423) CLK (Clock) GPIO 4
DAT (Data Out) GPIO 5

demo video

code

  • Adafruit_Zero_I2S_Library == SAMD MCUs only

https://github.com/sheaivey/ESP32-AudioInI2S

https://github.com/atomic14/esp32_audio == platformIO-dat

https://github.com/schreibfaul1/ESP32-audioI2S == easy

https://github.com/earlephilhower/ESP8266Audio

Micropython driver

https://github.com/miketeachman/micropython-i2s-examples

ESP32 I2S MEMS Microphone Arduino IDE Example This repository holds some samples for connecting a I2S MEMS microphone to an ESP32 board.

https://github.com/miketeachman/micropython-i2s-examples

app

ref

audio amplifer - audio-dat - amplifier-dat - CS4344-dat

https://en.wikipedia.org/wiki/I%C2%B2S