Audio Player Built with ESP32 for DIY Projects
Building your own music player can be a lot of fun, and in the past, we've constructed a few DIY music players by utilizing Arduino and a specialized MP3 module. Now that we have ESP32, w…

Know the mission before touching a wire.
Understand what you are making, prepare the right tools, and make the workbench safe.
Project details
Audio Player Built with ESP32 for DIY Projects is a iot project. Building your own music player can be a lot of fun, and in the past, we've constructed a few DIY music players by utilizing Arduino and a specialized MP3 module. Now that we have ESP32, w…
- Source pages
- 1377-1382
- Named parts
- 3
- Build goal
- Working, tested prototype
Tools you need
- Digital multimeter
- Wire stripper and side cutters
- Soldering iron with a fine tip
- Current-limited bench supply
- Computer with a data-capable USB cable
Use eye protection, good lighting, and a clean insulated surface throughout the build.
Safety precautions
- Disconnect every power source before changing a connection.
- Check component polarity, pinout, and supply voltage twice.
- Use a current limit for the first power-up.
- Keep liquids, loose metal, and uninsulated wires away from the bench.
Gather, identify, and understand every part.
Use the standardized inventory, then open What's this? to learn each part's role, advantages, limitations, handling, and specifications.
What's this?Image, role, pros, cons, handling & specifications

ESP32
A programmable controller that reads inputs, makes decisions, and drives the project's outputs.
What it does hereIt is the control centre and must use the documented board, pin map, supply, and logic level.
Buy / compare this part ↗Advantages
- Reprogrammable and reusable
- Large learning ecosystem
- Complex behaviour remains changeable
Limitations
- GPIO voltage and current are limited
- Some pins affect boot or communication
- Loads normally need a driver
Handling
- Disconnect power before rewiring
- Avoid static discharge
- Never power motors, relays, or pumps directly from GPIO
Specifications to verify
- Use the exact model, value, package, and rating listed for ESP32; similar-looking parts are not always interchangeable.
- Confirm operating voltage, logic level, pinout, memory, USB interface, and maximum GPIO current.
What's this?Image, role, pros, cons, handling & specifications
SEMICONDUCTOR LEARNING VIEWLM386 Amplifier Module
A semiconductor stage performs switching, amplification, regulation, rectification, or logic.
What it does hereIt controls current or signal flow at a defined point in the circuit.
Buy / compare this part ↗Advantages
- Fast and efficient
- Compact
- Can control larger loads from smaller signals
Limitations
- Pin order varies
- Sensitive to overvoltage and reverse polarity
- May need cooling or bias components
Handling
- Verify the datasheet pinout
- Avoid static and soldering heat
- Check notch, stripe, or flat-face orientation
Specifications to verify
- Use the exact model, value, package, and rating listed for LM386 Amplifier Module; similar-looking parts are not always interchangeable.
- Confirm pinout, maximum voltage/current, dissipation, gain or forward voltage, and package.
What's this?Image, role, pros, cons, handling & specifications

ohm Speaker
An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.
What it does hereIt presents the circuit result or acts on the physical world.
Buy / compare this part ↗Advantages
- Makes system state visible
- Can be tested separately
- Supports clear troubleshooting
Limitations
- Loads may exceed controller current
- Polarity or driver direction can matter
- Inductive loads create voltage spikes
Handling
- Use the documented driver stage
- Check polarity and load current
- Add flyback protection for inductive loads
Specifications to verify
- Use the exact model, value, package, and rating listed for ohm Speaker; similar-looking parts are not always interchangeable.
- Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
Connect one verified path at a time.
Explore the named components and standardized signal flow, then use Source Check to verify exact physical pins, values, and topology before applying power.
Trace this circuit.
Audio Player Built with ESP32 for DIY Projects: interactive parts, standardized terminals, responsive anchored wires, student explanations, and the original circuit reference in one shared system.
Trace before wiring
Follow power, ground, inputs, processing, and outputs in that order. Never guess a pin from package shape alone.
Connect with power off
Make short, labelled connections and share a common ground only where the schematic requires it.
Inspect every joint
Check continuity, polarity, adjacent shorts, and loose connections before the first power-up.
Open all source diagrams and build views 3 visuals



Prepare, upload, and verify the program.
Follow the same software sequence every time: verify connections, prepare the toolchain, compile, and upload.
How to connect
- Match every controller label to the circuit view and source pin map.
- Join grounds before signal wires when separate low-voltage supplies are used.
- Keep motors, relays, pumps, and other loads on a suitable driver and external supply.
Common mistakes
Reversed VCC/GND, board-label versus GPIO-number confusion, missing common ground, and charge-only USB cables.
Troubleshoot
Disconnect loads, continuity-test one path at a time, then test with a current limit.
Software preparation
- Install the current Arduino IDE or the software named in the guide.
- Install the correct board package and required libraries.
- Select the exact board, processor, and serial port.
- Compile once before connecting external loads.
How to upload code
- Connect the board with a data-capable USB cable.
- Open the documented sketch and confirm configuration values.
- Compile, fix the first reported error, and upload.
- Test with external loads disconnected first.
Common mistakes
Wrong port, missing library, incorrect board selection, boot pins held in the wrong state, or a busy serial port.
Code
This is the whole code for the Contactless ESP32 Audio Player. In this
section, we will go over some essential elements of the code. We are going
to make use of the XT DAC Audio library that is provided by XTronical in
this program. Download instructions for the XT DAC Audio library can be
found on this page.
Therefore, begin the code as you normally would by incorporating all of the
necessary libraries. The hexadecimal representation of the.WAV file that
will be played can be found in the SoundData.h file.
Testing the ESP32 Audio PlayerCode
#include "SoundData.h"
#include "XT_DAC_Audio.h"
XT_Wav_Class Sound(sample);
XT_DAC_Audio_Class DacAudio(25,0);
uint32_t DemoCounter=0;
void setup() {
Serial.begin(115200);
}
void loop() {
DacAudio.FillBuffer();
if(Sound.Playing==false)
DacAudio.Play(&Sound);
Serial.println(DemoCounter++);
}
When you are satisfied with the code, connect the speaker to GPIO 25 of
the ESP32 using an amplifier module such as LM386 or any other type.
Now you can upload the code by connecting the ESP32 to your laptop. The
Audio will begin to play as soon as the code is uploaded to the ESP32. The
Amplifier module features a potentiometer that allows for the quality of the
sound to be adjusted.Assemble, deploy, test, and troubleshoot.
Use the complete source notes in build order, then pass the final checks before calling the project finished.
Build in functional stages
- Power and regulation
- Controller or processing stage
- Inputs and sensors
- Outputs and loads
- Enclosure and strain relief
Power up safely
- Inspect unpowered continuity first
- Apply the lowest safe current limit
- Measure supply rails before signals
- Add one load at a time
- Record expected and actual results
Work from simple to complex
- Confirm power, ground, polarity, and orientation
- Compare each pin with the source
- Test inputs separately from outputs
- Replace only one variable at a time
- Power off before every correction
Follow the documented instructions.
These notes come from this project's source and remain in their original order.
Project overview
Project build noteBuilding your own music player can be a lot of fun, and in the past, we've constructed a few DIY music players by utilizing Arduino and a specialized MP3 module. Now that we have ESP32, we are building an interesting audio player with it.
If you want to add sound effects, all you have to do is attach an additional speaker to ESP32. To play audio files, we will make use of an LM386 and a speaker in conjunction with an ESP32. This program demonstrates that the ESP32 board is capable of playing audio files, despite the relatively quiet volume of the audio output.
Components Required
Project build noteESP32 LM386 Amplifier Module 8-ohm Speaker Jumper Wires
Circuit Description
Project build noteA speaker is required in order for the ESP32 to play sound. The LM386 Audio Amplifier module is what establishes the connection to the speaker.
While the GPIO 25 pin of the ESP32 is linked to the IN pin of the Amplifier Module, the Vcc and GND pins of the Amplifier Module are connected to the VIN and GND pins of the ESP32. DAC stands for "digital to analog converter," and one of the two DAC pins is GPIO 25.
Getting Ready with Audio Files We require audio files that are in the.wav format in order to play audio sounds on the ESP32 board since the ESP32 can only play an audio file that is in the.wav format. Therefore, the first thing you will need to do is obtain the file that you wish to play on the ESP32. After that, you need download the Audacity Audio Editor app and then install it. Changing the file type, Sample Rate, and any other attributes will be accomplished with the assistance of this application.
After the installation is finished, launch the Audacity app, navigate to the "file" menu, pick "Open," and then navigate to the audio file you wish to edit. The sample rate is the first thing that has to be modified that has been brought up. Because the ESP32 doesn't have a lot of memory, you should use a sample rate that is between 8000 and 16000 if you want to play an audio file on it. Make the necessary adjustment and set the Project Rate to 16000. After that, to save the audio file in.wav format, go to the File menu, then click Export, and then click Export as WAV. Click on the Save button once you have chosen WAV (Microsoft) as the type of file to save and Unsigned 8-bit PCM as the encoding format in the next box. At this point, we require an application known as a Hex Editor in order to generate Hex codes for the audio file. Therefore, follow the link provided to obtain the Hex Editor (HxD) and proceed to install it. After that, launch the application, and then select File > open to bring up the.wav file for editing. The Hex code for the.wav file will be generated as a result of this action.
The code can then be copied into the C Language format by selecting it with the ctrl+A shortcut and then selecting Edit > Copy as > C from the menu bar.
You built Audio Player Built with ESP32 for DIY Projects.
You followed the full workflow from understanding the mission to testing the finished project. That is a real engineering achievement - well done.
Browse all 500 projects