Adding a speaker with I²S
Inter-IC Sound (I²S) is another type of data interface but for audio. Essentially, it has three lines for the following:
- Data, Data-In (DIN), or Data-Out (DOUT)
- Clock or bit clock (BCLK)
- Channel select, word select (WS), or left-right clock (LRCLK)
The interface is a standard; however, the naming is not, as we see above. The data line carries stereo audio data for both the left (channel 0) and right (channel 1) channels. The channel select signal indicates which channel data is currently being transferred: it is a low level for the left channel and a high level for the right channel. Finally, the clock line is a common clock for both ends provided by the master, which is usually the sending party in this type of communication.
ESP32 provides two I2S peripherals that can be configured as input or output. When configured as input, a mic can be used to sample the sound data and store it on the flash for later use. If it is...