I2S Standard
I2S (Inter-IC Sound) — pronounced "eye-two-ess" — is an electrical serial bus interface used for connecting digital audio devices together. It sends PCM (Pulse-Code Modulation) audio data between chips in an electronic device.
Key Idea
I2S and I2C sound almost identical but are completely different buses.
I2C is for sensors and slow devices. I2S is specifically for high-quality
digital audio — it is much faster and designed to keep audio in perfect time.
Why Use I2S?
A simple piezo buzzer can play tones, but it cannot play high-quality audio files. I2S lets you connect a proper digital-to-analog converter (DAC) or a digital amplifier to the Pico so you can play WAV files, synthesized music, and recorded speech at CD quality.
How I2S Works
I2S uses three wires:
| Wire | Name | Purpose |
|---|---|---|
| SCK | Serial Clock (Bit Clock) | Clocks each audio bit |
| WS | Word Select (Left/Right Clock) | Selects the left or right stereo channel |
| SD | Serial Data | The actual audio samples |
The clock rate depends on the audio quality you want. For standard 44.1 kHz stereo audio at 16-bit depth:
- SCK runs at 44 100 × 2 channels × 16 bits = 1.41 MHz
The Pico's I2S peripheral can handle this easily.
MicroPython I2S Support
Since MicroPython 1.17, the machine.I2S class lets you send and receive
I2S audio data. Here is a minimal example that plays a raw WAV file from
the Pico's flash storage using an I2S DAC module:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Common I2S DAC Modules
| Module | Chip | Channels | Cost |
|---|---|---|---|
| MAX98357A | MAX98357A | Mono, 3 W | ~$2 |
| PCM5102A | PCM5102A | Stereo | ~$3 |
| UDA1334A | UDA1334A | Stereo | ~$5 |
The MAX98357A is the most popular for beginners — it includes a speaker amplifier so you can connect a small speaker directly to it with no extra parts.
Monty's Tip
Convert your MP3 or music files to 16-bit 44.1 kHz WAV format before
copying them to the Pico. The Converting Audio Files
lab shows you exactly how to do this using free tools.
References
- Wikipedia — I2S
- MicroPython I2S Documentation
- The I2S Bus Lab — detailed wiring and usage examples