ESP32

Bluetooth Speaker using ESP32 and MAX98357 I2S Digital Amplifier

Bluetooth Speaker using ESP32:

Bluetooth Speaker using ESP32 and MAX98357 I2S Digital Amplifier– In my free time, I often go to the terrace of my house and sit there. I frequently either listen to songs or watch a movie on Netflix. However, I can’t fully enjoy it because the sound from my cell phone is not loud enough. I also don’t prefer using headphones because they could cause ear infections.

I already have a powerful amplifier system, but I can’t take it to the terrace, and I can’t take it camping either.




So, I thought why not to make myself a very simple Bluetooth Speaker. Because I already have the required components like the ESP32 WiFi + Bluetooth module and as you know it supports I2S Audio Outputs.

Bluetooth Speaker

I2S stands for “Inter-IC Sound” or “Integrated Interchip Sound,” is a digital audio interface standard used for transmitting digital audio data between integrated circuits (ICs) in electronic devices. It is commonly used in applications such as audio codecs, digital signal processors, and microcontrollers for processing and transmitting audio signals.

Bluetooth Speaker

I also have this digital amplifier based on the MAX98357 I2S Class D amplifier and this 3W and 8Ω speaker.

Bluetooth Speaker

So, for this project you only need these three components an ESP32 board, an amplifier module, and a speaker. So, without any further delay let’s get started!!!



Amazon Links:

ESP32 WiFi + Bluetooth Module(Recommended)

3W 8 Ohm Speaker

MAX98357 I2S amplifier

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.



MAX98357 I2S Amplifier Module:

Bluetooth Speaker

This I2S digital amplifier is based on the MAX98357 I2S Class D amplifier module, offering exceptional compatibility with microcontrollers equipped with I2S audio outputs, such as the ESP32 WiFi + Bluetooth Module. It can be used in projects like IoT nodes, smart home devices, Bluetooth audio players, and so on.

It features a PH2.0 connector and stamped holes for seamless speaker connections, enhancing its adaptability and user-friendliness.

The module supports 3.3V-5V power supply. And it can output over 2.5W of power when driven by 5V and a 4Ω speaker. Besides, it allows users to set different modes (off, left channel, right channel, and mixed) by changing the resistance on the SD port. The product defaults to be mixed mode. Featuring a small size, this I2S amplifier comes with stamp holes that enable it to be directly plugged into or mounted on a PCB and breadboard. Also, it is designed with PH2.0 and stamp holes for connecting speakers, flexible and convenient to use.

These are some of the Features and Specifications:

Features

  • MAX98357 I2S digital Class D amplifier, power >2.5W
  • 3.3V~5V voltage power supply
  • Switchable sound channel
  • Adjustable gain
  • Stamp holes design, support SMT and DIP
  • Two ways to connect a speaker: PH2.0 and stamp holes



Specification

  • MCU: MAX98357A
  • Operating Voltage: DC 3.3V~5V
  • Output Power: 8Ω 1.8W / 4Ω 2.5W (at 12db)
  • Output Channel: single channel
  • Communication Interface: I2S interface
  • Operating Temperature: -40℃ – +80℃
  • Storage Temperature: -40℃ – +80℃
  • Dimension (Without Packaging): 18mm × 18mm/ 0.059 × 0.059

Application

  • Bluetooth Audio Player
  • IoT Node Audio Player
  • Smart Home Voice Interaction
  • Robotic Device Audio Player



Board Overview:

in Function Remark
SPK- Speaker negative 4Ω/8Ω <3W
VCC Power input DC 3.3V-5V
GND Ground
NC Not connected pin
SD Turn off amplifier, adjust sound channel Refer to 4.1.2(SD Mode Description)
GAIN Adjust amplifier gain Default to 9dB/Refer to 4.1.1 Gain Control Description
SPK+ Speaker positive 4Ω/8Ω <3W
DIN Digital input signal
BCLK Bit clock input Bit Clock Input
LRC Frame clock Left/right clock of I2S and LJ mode. Synchronized clock in TDM mode



What is I2S?

I2S, which stands for “Inter-IC Sound” or “Integrated Interchip Sound,” is a digital audio interface standard used for transmitting digital audio data between integrated circuits (ICs) in electronic devices. It is commonly used in applications such as audio codecs, digital signal processors, and microcontrollers for processing and transmitting audio signals.

I2S is characterized by its separate data and clock lines, making it a straightforward and efficient method for transferring high-quality audio data. The standard typically uses three signal lines:

  • Serial Data (SD): This line carries the audio data in a serial bitstream format. It can be either left-justified, right-justified, or in I2S standard format, depending on the configuration.
  • Word Select (WS) or Frame Sync (FS): This line indicates the start of a new audio data word and helps the receiver distinguish between left and right audio channels.
  • Serial Clock (SCK): This line provides the clock signal that dictates the timing for the data transmission.

I2S is widely used in audio applications, such as connecting digital audio sources (like microphones and digital audio players) to audio processing components (like digital-to-analog converters and amplifiers). It enables high-fidelity audio transmission and is often found in consumer electronics, audio interfaces, and professional audio equipment.




3W and 8Ω Speaker:

Bluetooth Speaker

It’s a 3W and 8Ω Speakers with JST PH2.0 interface which nice plugs into the PH2.0 connector. It is perfect for any DIY audio project which requires an 8 ohm impedance and 3W power. And these are some of the specifications.

SPECIFICATION

Power: 3 W

Resistance: 8 Ω

Line length: 42 cm

Distortion: < 10%

Product size: 70 * 30 * 16 mm/2.76 * 1.18 * 0.63 inches

The pitch of screws: 24 * 63 mm/ 0.94 * 2.5 inches

Weight: 24 g



Bluetooth Speaker Circuit Diagram:

Bluetooth Speaker

Connect the VCC and GND pins of the MAX98357 amplifier module to the ESP32 3.3V and GND pins.

Connect LRC pin of the MAX98357 amplifier module to the GPIO26 on the ESP32.

Connect BCLK Pin to the GPIO27 pin on the ESP32.

Connect DIN to GPIO25.

Connect your speaker + and – wires to the amplifier module SPK+ AND SPK- pins. In my case, I am using the PH2.0 connector.



ESP32 Board installation in the Arduino IDE:

If this is your first time using an ESP32 board then first of all, you will need to install it in the Arduino IDE and for this you can read my article on the ESP32. It doesn’t matter if you are using another version of the ESP32 board. The installation is the same.

Once your ESP32 board is installed and its available in the Arduino IDE. Next, you will need to add ESP32-A2DP-MAIN library in the Arduino IDE.

Download: ESP32-A2DP-main

After downloading the above library, simply go to the Sketch Menu, then to Include Library, and click on the Add .Zip library.

Bluetooth Speaker

Browse to the location and select this library and press the open button.

Bluetooth Speaker

You will see a message that the library is added in the Arduino IDE. Now, finally, you can copy the following code and upload it into your ESP32 board.



Bluetooth Speaker Programming:

Bluetooth Speaker Testing:

To power this Bluetooth speaker system you can use a single cell Lithium-ion battery, you can also use a power bank which you can connect to the Micro USB port of the EPS32 board. But in my case, I am going to use my created 4S lithium Ion battery pack and I am not worried about the voltage, as my ESP32 development board already has a 5V regulator based on the 7805 voltage regulator. Anyway, I powered up my Bluetooth Speaker system using a 4S lithium Ion battery.

Now, all I need is to connect my cell phone to the Bluetooth Speaker and that’s it.

Bluetooth Speaker

I am quite impressed with the sound quality and the wireless range of my DIY Bluetooth Speaker is around 8 meters which is more than enough for me. So, that’s all for now.




Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button