Maker.io main logo

I2S Audio Breakout Hookup Guide

20

2026-09-04 | By SparkFun Electronics

DACs Wired I2S Movement Acceleration Microcontrollers Solder / Desoldering Irons / Stations Arduino ESP32 Thing Plus

Courtesy of SparkFun Electronics

Guide by Alex the Giant

Introduction

The I2S Audio Breakout board uses the MAX98357A digital to analog converter (DAC), which converts I2S (not be confused with I2C) audio to an analog signal to drive speakers. The MAX98357A has a built in class D amplifier which can deliver up to 3.2W of power into a 4Ω load. For more information, see the Hardware Overview section below.

Suggested Tools

You will need a soldering iron, solder, general soldering accessories, screw driver, and hobby knife.

Suggested Reading

If you aren't familiar with the following concepts, we recommend checking out these tutorials before continuing.

  • How to Solder: Through-Hole Soldering: This tutorial covers everything you need to know about through-hole soldering.
  • How to Power a Project: A tutorial to help figure out the power requirements of your project.
  • Button and Switch Basics: A tutorial on electronics' most overlooked and underappreciated component: the switch! Here we explain the difference between momentary and maintained switches and what all those acronyms (NO, NC, SPDT, SPST, ...) stand for.
  • ESP32 Thing Hookup Guide: An introduction to the ESP32 Thing's hardware features, and a primer on using the WiFi system-on-chip in Arduino.
  • How to Work with Jumper Pads and PCB Traces: Handling PCB jumper pads and traces is an essential skill. Learn how to cut a PCB trace, add a solder jumper between pads to reroute connections, and repair a trace with the green wire method if a trace is damaged.
  • ESP32 Thing Motion Shield Hookup Guide: Getting started with the ESP32 Thing Motion Shield to detect movements using the on-board LSM9DS1 IMU and adding a GPS receiver. Data can be easily logged by adding an microSD card to the slot.

Hardware Overview

The I2S audio breakout converts the digital audio signals using the I2S standard to an analog signal and amplifies the signal using a class D amplifier. The board can be configured to output only the left channel, right channel, or both. For more information about how to configure the board, refer to the Jumper Selection section below.

Image of I2S Audio Breakout Hookup Guide

Board Specs

Image of I2S Audio Breakout Hookup Guide

Pin Descriptions

The SparkFun I2S audio breakout board is fairly simple, requiring only a few pin connections to get the board working.

Image of I2S Audio Breakout Hookup Guide

Inputs

Image of I2S Audio Breakout Hookup Guide

Outputs

The output is where you'll connect your speaker.

Image of I2S Audio Breakout Hookup Guide

Image of I2S Audio Breakout Hookup Guide

Speaker wire can either be soldered directly to the output pads, but if screw terminals are more your style, you can use our 3.5mm screw terminals.

Jumper Selection

By default the board is configured in "mono" operation, meaning the left and right signals are combined together to drive a single speaker.

Image of I2S Audio Breakout Hookup Guide

If you want a separate speaker for the left and right audio channels you'll first need to cut the mono jumper as pictured below.

Image of I2S Audio Breakout Hookup Guide

To configure the board to respond to a specific audio channel, you'll need to close the stereo jumper as shown below.

Image of I2S Audio Breakout Hookup Guide

Gain Selection

In addition to being able to select the audio channel output, the gain can also be configured in a few ways. The gain of the amplifier can be configured from as low as +3dB to as high as +15dB. While the channel selection can be configured on board, the gain however is controlled externally using the gain pin. By default, the board is configured for +9dB, but can be changed using the table below.

Image of I2S Audio Breakout Hookup Guide

Examples

Note: These example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

This board should work with any microcontroller or single board computer that has I2S capable pins. In these examples, we're going to look at a pretty powerful library that allows you to use an ESP32 Thing to play audio from a wide variety of sources. First, we'll play an audio file which is stored in the ESP32's program memory, and once we have that working we'll look at creating a MP3 trigger. The following libraries are needed to run the examples that were originally written for the ESP8266, but also work with the ESP32.

ESP8266Audio Arduino Library

You'll need to install the ESP8266 Audio Arduino Library, written by Earle F. Philhower, which you can get from the link below. This library will allow you to play a wide variety of audio formats including: AAC, FLAC, MIDI, MOD, MP3, RTTTL, and WAV. To use the library, you can add the library from Arduino by selecting Sketch ** > **Include Library ** > **Add .ZIP Library... and selecting the .zip file from wherever you store your file downloads.

ESP8266 Audio Library (ZIP)

ESP8266_Spiram Arduino Library

The ESP8266 Audio library depends on the ESP8266 Spiram library, written by Giancarlo Bacchio, which will also need to be downloaded. You can download the library from the link below. Installing the library follows the same process as outlined above.

ESP8266 Spiram Library (ZIP)

First Test

In this first example, we'll run a quick example sketch to make sure the I2S audio breakout board is wired correctly and is working.

Image of I2S Audio Breakout Hookup Guide

Required Materials

The parts used in this example are listed in the Wishlist below. You may not need everything though depending on what you have. Add it to your cart, read through the example, and adjust the cart as necessary.

I2S Audio Breakout Hookup Guide Example 1

Hookup Table

The connections that need to be made to the ESP32 are list below.

Image of I2S Audio Breakout Hookup Guide

Make sure to also connect a speaker to the I2S audio breakout board's output pins.

Example Code

We're going to use one of the examples that comes with the library named "PlayAACFromPROGMEM". With the library installed, open the example located in: File > Examples > ESP8266Audio > PlayAACFromPROGMEM.

Image of I2S Audio Breakout Hookup Guide

Before we upload the code, we're going to add two lines of code (as highlighted in the image below). The first line is going to adjust the volume, which we add after we initialize the I2S output (out = new AudioOutputI2S();). After the output is initialized, we're going to add out -> SetGain(0.125);. As the name suggests this sets the gain of the output, which takes a floating point number and has a maximum value of 4.0. The second line will reduce hum at the end of the audio clip by adding aac -> stop(); in the else statement in the main loop(). After you upload the sketch to your ESP32, you should hear Homer Simpson's thoughts of perpetual motion machines if everything is working.

Image of I2S Audio Breakout Hookup Guide

ESP32 MP3 Trigger

Now that we know the board is working, let's take it up a notch. In this next example, we'll create a MP3 trigger that works similar to our MP3 Trigger.

Image of I2S Audio Breakout Hookup Guide

Required Materials

For this example, we'll need to add a few more parts to the ones we used in the previous example (including a second breadboard). You may not need everything though depending on what you have. Add it to your cart, read through the example, and adjust the cart as necessary.

I2S Audio Breakout Hookup Guide Example 2

Before we add code, we'll need some audio files to play. Any MP3 audio file should work, you'll just need to copy them over to your microSD card using a microSD USB Reader. Before ejecting the microSD card from your computer, make sure to relabel the files TRACKn.mp3, where n is a integer number between 0-9. The I2S audio breakout board has the same pin connections as the previous example, but this time we're going to change the audio source from PROGMEM to our microSD card. The last step before adding the code below, is to add headers to the ESP32 Thing, as well as the Motion Shield, as outlined in the hookup guide.

Copy Code
/* SparkFun I2S Audio Breakout Demo
 * Created by: Alex Wende
 * 8/3/2018
 * 
 * Uses a ESP32 Thing to create a MP3 trigger using 
 * the I2S Audio Breakout board.
 * 
 * Parts you'll need:
 * - I2S Audio Breakout board (https://www.sparkfun.com/products/14809)
 * - ESP32 Thing (https://www.sparkfun.com/products/13907)
 * - Micro SD Breakout (https://www.sparkfun.com/products/544)
 * - A microSD card (https://www.sparkfun.com/products/13833)
 * - Speaker (4-8ohms)
 * 
 * The following libraries need to be installed before
 * uploading this sketch:
 * - ESP8266 Audio (https://github.com/earlephilhower/ESP8266Audio)
 * - SRam Library (https://github.com/Gianbacchio/ESP8266_Spiram)
 */

#include <Arduino.h>
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
#include "AudioFileSourceSD.h"
#include "driver/i2s.h"
#include <SD.h>

//define trigger pins
#define TRIGGER0 13
#define TRIGGER1 12
#define TRIGGER2 14
#define TRIGGER3 27
#define TRIGGER4 32
#define TRIGGER5 5
#define TRIGGER6 15
#define TRIGGER7 2
#define TRIGGER8 0
#define TRIGGER9 4

//Initialize ESP8266 Audio Library classes
AudioGeneratorMP3 *mp3;
AudioFileSourceSD *file;
AudioOutputI2S *out;

volatile bool playing = 0;
volatile byte loadTrack = 0;

//External Interrupt function with software switch debounce
void IRAM_ATTR handleInterrupt()
{
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();
  // If interrupts come faster than 200ms, assume it's a bounce and ignore
  if (interrupt_time - last_interrupt_time > 200) 
  {
    //Figure out which switch was triggered, and which track to play
    if(!digitalRead(TRIGGER0)) loadTrack = 1;
    else if(!digitalRead(TRIGGER1)) loadTrack = 2;
    else if(!digitalRead(TRIGGER2)) loadTrack = 3;
    else if(!digitalRead(TRIGGER3)) loadTrack = 4;
    else if(!digitalRead(TRIGGER4)) loadTrack = 5;
    else if(!digitalRead(TRIGGER5)) loadTrack = 6;
    else if(!digitalRead(TRIGGER6)) loadTrack = 7;
    else if(!digitalRead(TRIGGER7)) loadTrack = 8;
    else if(!digitalRead(TRIGGER8)) loadTrack = 9;
    else if(!digitalRead(TRIGGER9)) loadTrack = 10;
    playing = 1;
  }
  last_interrupt_time = interrupt_time;
}

void setup()
{  
  Serial.begin(115200);

  //Configure trigger pins to inputs with internal pull-up resistors enabled
  pinMode(TRIGGER0,INPUT_PULLUP);
  pinMode(TRIGGER1,INPUT_PULLUP);
  pinMode(TRIGGER2,INPUT_PULLUP);
  pinMode(TRIGGER3,INPUT_PULLUP);
  pinMode(TRIGGER4,INPUT_PULLUP);
  pinMode(TRIGGER5,INPUT_PULLUP);
  pinMode(TRIGGER6,INPUT_PULLUP);
  pinMode(TRIGGER7,INPUT_PULLUP);
  pinMode(TRIGGER8,INPUT_PULLUP);
  pinMode(TRIGGER9,INPUT_PULLUP);

  //Create interrupts for each trigger
  attachInterrupt(digitalPinToInterrupt(TRIGGER0),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER1),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER2),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER3),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER4),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER5),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER6),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER7),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER8),handleInterrupt,FALLING);
  attachInterrupt(digitalPinToInterrupt(TRIGGER9),handleInterrupt,FALLING);

  out = new AudioOutputI2S();
  mp3 = new AudioGeneratorMP3();

  delay(1000);
  Serial.print("Initializing SD card...");
  if (!SD.begin(33))
  {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  delay(100);
}

void loop()
{
  if(loadTrack) //Load the track we want to play
  {
    //Stop the current track if playing
    if(playing && mp3->isRunning()) mp3->stop();

    if(loadTrack == 1) file = new AudioFileSourceSD("/TRACK0.mp3");
    else if(loadTrack == 2) file = new AudioFileSourceSD("/TRACK1.mp3");
    else if(loadTrack == 3) file = new AudioFileSourceSD("/TRACK2.mp3");
    else if(loadTrack == 4) file = new AudioFileSourceSD("/TRACK3.mp3");
    else if(loadTrack == 5) file = new AudioFileSourceSD("/TRACK4.mp3");
    else if(loadTrack == 6) file = new AudioFileSourceSD("/TRACK5.mp3");
    else if(loadTrack == 7) file = new AudioFileSourceSD("/TRACK6.mp3");
    else if(loadTrack == 8) file = new AudioFileSourceSD("/TRACK7.mp3");
    else if(loadTrack == 9) file = new AudioFileSourceSD("/TRACK8.mp3");
    else if(loadTrack == 10) file = new AudioFileSourceSD("/TRACK9.mp3");

    out -> SetGain(0.08); //Set the volume
    mp3 -> begin(file,out); //Start playing the track loaded
    loadTrack = 0;
  }

  if(playing && mp3->isRunning()) {
    if (!mp3->loop())
    {
      mp3->stop();
      playing = 0;
      Serial.println("Stopped");
    }
  }
}

With the code on the board, we can see what the sketch does. You can connect momentary pushbutton switches to each of the trigger pins outlined in the table below, with the other end of the switch connected to ground. Another option is to take a ground wire and touch it to one of the trigger pins. When the pin is pulled down to ground, it triggers the corresponding track to play. If a track is still playing when a new pin is triggered, that track will stop and the new track will play.

Image of I2S Audio Breakout Hookup Guide

Resources and Going Further

Now that we know how to use the I2S Audio Breakout board, it's time to use it in your own project! For more information on the I2S audio breakout, checkout the links below:

Mfr Part # 14809
SPARKFUN I2S AUDIO BREAKOUT - MA
SparkFun Electronics
Mfr Part # 09325
SOLDER LEAD FREE - 100-GRAM SPOO
SparkFun Electronics
Mfr Part # 09200
HOBBY KNIFE
SparkFun Electronics
Mfr Part # 12891
POCKET SCREWDRIVER SET
SparkFun Electronics
Mfr Part # WE1010NA
SOLDERING STATION 70W 1 CH 120V
Apex Tool Group
$197.50
View More Details
Mfr Part # 08084
SCREW TERMINALS 3.5MM PITCH (2-P
SparkFun Electronics
Mfr Part # COM-19102
SPEAKER 4OHM 10W TOP PORT 85DB
SparkFun Electronics
Mfr Part # 12002
BREADBOARD - SELF-ADHESIVE (WHIT
SparkFun Electronics
Mfr Part # 13907
SPARKFUN ESP32 THING
SparkFun Electronics
Mfr Part # 00116
BREAK AWAY HEAD
SparkFun Electronics
Mfr Part # 13720
EVAL BOARD FOR CY8C29466 VS1063
SparkFun Electronics
Mfr Part # 14430
ESP32 THING MOTION SHIELD
SparkFun Electronics
Mfr Part # 14311
ESP32 STACKABLE HEADER SET
SparkFun Electronics
Mfr Part # 00097
SWITCH TACTILE SPST-NO
SparkFun Electronics
Add all DigiKey Parts to Cart
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.