🛠 I2S Amplifier with ESP32 for Stereo Audio

Adafruit Stereo I2S 3W Amplifier Breakout - Dual MAX98357A · debutant · Connectez l'amplificateur Adafruit MAX98357A à un ESP32 pour diffuser de l'audio stéréo numérique haute fidélité.

Objectifs

This tutorial guides you through connecting the Adafruit Stereo I2S 3W Amplifier Breakout to an ESP32 microcontroller. The goal is to understand how to use the I2S (Inter-IC Sound) interface to transmit digital audio data without intermediate analog conversion. You will learn to power the circuit correctly, respect specific pinouts (BTL), and configure the gain for clear audio output. This setup is ideal for internet radio, MP3 player, or notification system projects.

Matériel nécessaire

Étapes

  1. Physical Preparation: Solder male headers to the amplifier board if not already done. Ensure speakers are disconnected before powering up to avoid damage.
  2. Power Connection: Connect the amplifier's VIN pin to the ESP32's 5V. Connect the amplifier's GND pin to the ESP32's GND. The amplifier operates between 2.7V and 5.5V, so 5V is optimal.
  3. I2S Signal Connection: The I2S interface requires three data lines. Connect the ESP32 pins to the corresponding amplifier pins:

*Note: ESP32 uses these GPIOs by default for I2S, but verify your specific board's documentation.*

  1. Gain Configuration: By default, gain is set to 9dB. To change it, use jumpers on the GAIN1 and GAIN2 pads. For this tutorial, leave default settings for moderate power.
  2. Speaker Connection: This is the critical step. The amplifier uses a BTL (Bridge Tied Load) topology. This means there is no common ground at the speaker terminals. Connect L+ output to the positive terminal of the left speaker and L- to the negative. Do the same for the right channel (R+ and R-). Never connect L- or R- to the ESP32's GND.
  3. Programming: Open the "i2s" example in the Arduino IDE for the ESP32 board. Modify pins if necessary to match physical connections (BCLK=26, LRC=25, DIN=22). Upload the code.

Vérification

Once the code is uploaded, the ESP32 should broadcast a test signal (often a sine wave or white noise).

Pour aller plus loin

Explore advanced audio libraries like ArduinoJson to create internet radio streams. You can also integrate a temperature sensor to trigger audio alerts. For maximum quality, ensure I2S cables are short to reduce electromagnetic interference.

Other tutorials for this board

← Back to the board 🛠 All tutorials