{"id":189809,"date":"2026-04-30T15:39:19","date_gmt":"2026-04-30T15:39:19","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=189809"},"modified":"2026-04-30T15:39:22","modified_gmt":"2026-04-30T15:39:22","slug":"esp32-play-audio-mp3-wav-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-play-audio-mp3-wav-arduino\/","title":{"rendered":"ESP32: Play Sound or Audio .mp3\/.wav Files using YX5300 (Arduino IDE)"},"content":{"rendered":"\n<p>Learn how to play <em>.mp3<\/em> or <em>.wav<\/em> audio files stored on microSD card using an ESP32. We&#8217;ll be using the YX5300 \/ YX6300 Serial MP3 Music Player Module wired to an ESP32 board and programmed with Arduino IDE.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Guide YX5300 YX6300 MP3 Player Module Play Sound Arduino IDE\" class=\"wp-image-189807\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p><strong>Recommended reading:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp32-yx5300-yx6300-mp3-player-arduino\/\">[Extended Guide] ESP32 with YX5300\/YX6300 MP3 Player (Arduino IDE)<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"intro-YX5300\">Introducing the YX5300 \/ YX6300 Serial MP3 Music Player Module<\/h2>\n\n\n\n<p>The <a href=\"https:\/\/makeradvisor.com\/tools\/yx5300-yx6300-serial-mp3-music-player-module\/\" target=\"_blank\" rel=\"noopener\" title=\"\">YX5300 \/ YX6300<\/a> is a low-cost Serial (UART) MP3 music player module that can be interfaced with microcontrollers (such as the ESP32, ESP8266, or Arduino) to play <em>.mp3<\/em> or <em>.wav<\/em> files stored on a MicroSD card by sending serial commands.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"423\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Front-Pinout-Headphone-Jack.JPG.jpg?resize=750%2C423&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"YX5300 YX6300 MP3 Player Serial Module Front Pinout Headphone Jack\" class=\"wp-image-189805\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Front-Pinout-Headphone-Jack.JPG.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Front-Pinout-Headphone-Jack.JPG.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Where to Buy?<\/h3>\n\n\n\n<p>You can check our Maker Advisor Tools page to compare the YX5300 \/ YX6300 module price in different stores:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/makeradvisor.com\/tools\/yx5300-yx6300-serial-mp3-music-player-module\/\" target=\"_blank\" rel=\"noopener\" title=\"\">YX5300 \/ YX6300 Serial MP3 Music Player Module<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<p>You will also need an&nbsp;<a href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 development board<\/a>&nbsp;model of your choice.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"YX5300-wiring\">Wiring the YX5300 \/ YX6300 Serial MP3 Music Player to the ESP32<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"417\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Front-Pinout-Highlight.jpg?resize=750%2C417&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"YX5300 YX6300 MP3 Player Serial Module Front Pinout Highlight\" class=\"wp-image-189814\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Front-Pinout-Highlight.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Front-Pinout-Highlight.jpg?resize=300%2C167&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Wiring the MP3 player to the ESP32 is quite simple, as it only requires two serial pins: <strong>RX<\/strong> and <strong>TX<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>YX5300 \/ YX6300<\/strong><\/td><td><strong>ESP32<\/strong><\/td><\/tr><tr><td>TX<\/td><td><span class=\"rnthl rntclgreen\">GPIO 16<\/span> (UART 2 RX)<\/td><\/tr><tr><td>RX<\/td><td><span class=\"rnthl rntclblue\">GPIO 17<\/span> (UART 2 TX)<\/td><\/tr><tr><td>VCC<\/td><td><span class=\"rnthl rntcred\">VIN<\/span> (5V)<\/td><\/tr><tr><td>GND<\/td><td><span class=\"rnthl rntcblack\">GND<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>According to the product specifications in the manual, the VCC works with voltages between 3.2V-5.2V. According to our testing, it works most reliably when connected to 5V (VIN).<\/p>\n\n\n\n<p>* you can use any other RX\/TX GPIOs. Check the ESP32 Pinout Guide:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-pinout-reference-gpios\/\">ESP32 Pinout Reference: Which GPIO pins should you use?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-s3-devkitc-pinout-guide\/\">ESP32-S3 DevKitC Pinout Reference Guide: GPIOs Explained<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclgreen\">You may also like: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-uart-communication-serial-arduino\/\">ESP32 UART Communication (Serial): Set Pins, Interfaces, Send and Receive Data (Arduino IDE)<\/a>.<\/p>\n\n\n\n<p>We&#8217;ll connect the RX pin to <span class=\"rnthl rntclblue\">GPIO 17<\/span>, and the TX pin to <span class=\"rnthl rntclgreen\">GPIO 16<\/span>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"475\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-Play-Sounds-Wiring-Circuit.png?resize=900%2C475&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 YX5300 YX6300 MP3 Player Play Sounds Wiring Circuit\" class=\"wp-image-189796\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-Play-Sounds-Wiring-Circuit.png?w=900&amp;quality=100&amp;strip=all&amp;ssl=1 900w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-Play-Sounds-Wiring-Circuit.png?resize=300%2C158&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-Play-Sounds-Wiring-Circuit.png?resize=768%2C405&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgray\"><strong>Important:<\/strong> in all projects that use serial commands, you need to connect the pins TX-RX and the RX-TX. However, if the code is not running properly (not sending\/receiving serial commands), you might need to swap the wiring and connect RX-RX and TX-TX. One of our Serial MP3 players came with the wrong labels on the module, and the only way it worked was connected with TX-TX and RX-RX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Preparing Arduino IDE<\/h2>\n\n\n\n<p>We\u2019ll program the ESP32 board using Arduino IDE. So, make sure you have the ESP32 add-on installed. Follow the next tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\">Install the ESP32 Board in Arduino IDE<\/a><\/li>\n<\/ul>\n\n\n\n<p>If you prefer using VSCode + PlatformIO, follow the next tutorial instead:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/vs-code-platformio-ide-esp32-esp8266-arduino\/\">Getting Started with VS Code and PlatformIO IDE for ESP32 and ESP8266<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"YX5300-library\">Installing the YX5300 for ESP32 Library (YX6300 compatible)<\/h2>\n\n\n\n<p>There are several libraries to interface the YX5300 serial module with the ESP32. We&#8217;ll use the <strong><a href=\"https:\/\/github.com\/bluejunimo\/YX5300_ESP32\" target=\"_blank\" rel=\"noopener\" title=\"\">YX5300_ESP32 library by bluejunimo<\/a><\/strong> (even though the library is called YX5300 for ESP32, it&#8217;s also fully compatible with the YX6300 MP3 module without any additional changes).<\/p>\n\n\n\n<p>You can install the library via the Arduino IDE library Manager. Search for <strong>YX5300 for ESP32<\/strong> and install the library by bluejunimo.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"493\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/Installing-YX5300-YX6300-for-ESP32-MP3-Player-Serial-Arduino-IDE.png?resize=579%2C493&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing YX5300 YX6300 for ESP32 MP3 Player Serial Arduino IDE\" class=\"wp-image-189813\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/Installing-YX5300-YX6300-for-ESP32-MP3-Player-Serial-Arduino-IDE.png?w=579&amp;quality=100&amp;strip=all&amp;ssl=1 579w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/Installing-YX5300-YX6300-for-ESP32-MP3-Player-Serial-Arduino-IDE.png?resize=300%2C255&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 579px) 100vw, 579px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"microsd-card\">Preparing the MicroSD Card<\/h2>\n\n\n\n<p>The YX5300 MP3 player has a microSD card slot where you can insert a <a href=\"https:\/\/makeradvisor.com\/tools\/microsd-card-raspberry-pi-16gb-class-10\/\" target=\"_blank\" rel=\"noopener\" title=\"\">microSD card<\/a> to store your <em>.mp3 or .wav<\/em> files. Here are the main specifications that the module supports.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>YX5300<\/strong><\/td><td><strong>Value<\/strong><\/td><\/tr><tr><td>Supported MicroSD Cards<\/td><td>MicroSD &lt;= 32GB<\/td><\/tr><tr><td>Card Format<\/td><td>FAT16 \/ FAT32<\/td><\/tr><tr><td>Track Formats<\/td><td>.mp3 \/ .wav<\/td><\/tr><tr><td>Frequencies<\/td><td>8-48 kHz<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Before proceeding with the tutorial, make sure you&nbsp;<strong>format your microSD card as FAT32<\/strong>. Follow the next instructions to format your microSD card or use a software tool like&nbsp;<a href=\"https:\/\/www.sdcard.org\/downloads\/formatter\/\" target=\"_blank\" rel=\"noreferrer noopener\">SD Card Formater<\/a>&nbsp;(compatible with Windows and Mac OS).<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;Insert the microSD card into your computer. Go to&nbsp;<strong>My Computer<\/strong>&nbsp;and right-click on the SD card. Select&nbsp;<strong>Format&nbsp;<\/strong>as shown in the figure below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"431\" height=\"573\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/05\/format-SD-card-1.png?resize=431%2C573&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"format microSD card\" class=\"wp-image-61731\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/05\/format-SD-card-1.png?w=431&amp;quality=100&amp;strip=all&amp;ssl=1 431w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/05\/format-SD-card-1.png?resize=226%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 226w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/figure><\/div>\n\n\n<p><strong>2.&nbsp;<\/strong>A new window pops up. Select&nbsp;<strong>FAT32<\/strong>, press&nbsp;<strong>Start<\/strong>&nbsp;to initialize the formatting process and follow the onscreen instructions.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"254\" height=\"463\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/05\/format-SD-card-2.png?resize=254%2C463&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"format microsd card fat32 windows\" class=\"wp-image-61732\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/05\/format-SD-card-2.png?w=254&amp;quality=100&amp;strip=all&amp;ssl=1 254w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/05\/format-SD-card-2.png?resize=165%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 165w\" sizes=\"(max-width: 254px) 100vw, 254px\" \/><\/figure><\/div>\n\n\n<p><strong>3.<\/strong> In order to play music tracks, you must have folders and your files named correctly, so the MP3 module can access them. Here&#8217;s an example of the folder and filename structure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>01\/\n001xxx.mp3\n002xxx.mp3\n003xxx.mp3\n02\/\n004xxx.mp3\n005xxx.mp3\n03\/\n006xxx.mp3\n007xxx.mp3\n008xxx.mp3<\/code><\/pre>\n\n\n\n<p>Your folders must have 2-digits and each tracks needs to start with 3-digit. Each track name must be unique. Note: there is a maximum of 99 folders with 255 songs in each folder.<\/p>\n\n\n\n<p>Example, start by creating 2 folders in your microSD card (name your folders: <em>01 <\/em>and <em>02<\/em>):<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"336\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Folder-Structure.png?resize=717%2C336&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"YX5300 YX6300 MP3 Player Serial Module Folder Structure\" class=\"wp-image-189804\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Folder-Structure.png?w=717&amp;quality=100&amp;strip=all&amp;ssl=1 717w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Folder-Structure.png?resize=300%2C141&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/figure><\/div>\n\n\n<p><strong>4.<\/strong> Copy <em>.mp3<\/em> or <em>.wav<\/em> files, starting with <em>001<\/em>, <em>002<\/em>, and <em>003<\/em>. The file names must be sequencial and start with 3-digits.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"336\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Folder-and-Filenames.png?resize=731%2C336&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"YX5300 YX6300 MP3 Player Serial Module Folder and Filenames\" class=\"wp-image-189958\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Folder-and-Filenames.png?w=731&amp;quality=100&amp;strip=all&amp;ssl=1 731w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Folder-and-Filenames.png?resize=300%2C138&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/figure><\/div>\n\n\n<p><strong>5. <\/strong>Finally, remove the microSD card from you computer and attach it to the YX5300 module.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Module-Back-with-MicroSD-Card.JPG.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"YX5300 YX6300 MP3 Player Module Back with MicroSD Card\" class=\"wp-image-189801\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Module-Back-with-MicroSD-Card.JPG.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Module-Back-with-MicroSD-Card.JPG.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>You can <a href=\"https:\/\/github.com\/sarasantos\/rfmusic\/raw\/refs\/heads\/main\/Royalty_Free_Music.zip\" target=\"_blank\" rel=\"noopener\" title=\"\"><strong>click here to download a <em>.zip<\/em> folder with the royalty free music files<\/strong><\/a> used for this project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"headphones-speakers\">Connecting Headphones or Speakers to the YX5300 Module<\/h2>\n\n\n\n<p>The YX5300 doesn&#8217;t come with any headphones or speakers, but you can use some heaphones similar to the ones illustrated in the image below and plug them into the module headphone jack.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/Headphone-speaker-examples.JPG.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Headphone speaker examples\" class=\"wp-image-189800\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/Headphone-speaker-examples.JPG.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/Headphone-speaker-examples.JPG.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"play-sound\">Code &#8211; Play Sound .mp3\/.wav files using the YX5300 \/ YX6300 MP3 Player<\/h2>\n\n\n\n<p>The following code is the one provided by the library to play some with the YX5300 MP3 player module connected to an ESP32. It will play the audio files stored in the microSD card through the headphone or speaker.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp32-yx5300-yx6300-mp3-player-arduino\/\n  Example based on the library example by bluejunimo https:\/\/github.com\/bluejunimo\/YX5300_ESP32\/\n*********\/\n#include &lt;YX5300_ESP32.h&gt;\n\n\/\/ Connect to YX5300 Serial pins (RX and TX)\n#define RX 16\n#define TX 17\n\n\/\/ mp3 object\nYX5300_ESP32 mp3;\n\nvoid setup() {\n  \/\/ Initialize connection with the YX5300\/YX6300 module\n  mp3 = YX5300_ESP32(Serial2, RX, TX);\n  \n  \/\/ Shows the hex commands being sent to the mp3 device (includes helpful errors)\n  Serial.begin(115200);\n  mp3.enableDebugging();\n\n  \/\/ Plays the first track stored on the microSD Card (Track Formats .mp3\/.wav | Frequencies 8-48 kHz)\n  \/\/ MicroSD Card folder and file structure, example folder name 01 and file name 001xxx.mp3:\n  \/\/ 01\/001xxx.mp3   01\/002xxx.mp3   01\/003xxx.mp3   02\/004xxx.mp3\n  mp3.playTrack(1);\n}\n\nvoid loop() {\n  \/\/ put your main code here, to run repeatedly:\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP32\/ESP32_YX5300_YX6300_Play_Track.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Let&#8217;s break down how the code works.<\/p>\n\n\n\n<p><strong>Include YX5300_ESP32 library<\/strong><\/p>\n\n\n\n<p>First, you need to include the <span class=\"rnthl rntliteral\">YX5300_ESP32.h<\/span> library created by bluejunimo that will make it very easy to interface with the MP3 player module<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;YX5300_ESP32.h&gt;<\/code><\/pre>\n\n\n\n<p><strong>Initialize the YX5300<\/strong><\/p>\n\n\n\n<p>Set the YX5300 RX and TX pins and create an object for the module called <span class=\"rnthl rntliteral\">mp3<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define RX 16\n#define TX 17\n\nYX5300_ESP32 mp3;<\/code><\/pre>\n\n\n\n<p><strong>setup()<\/strong><\/p>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, start by initializing the module with the a specific Serial channel.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>mp3 = YX5300_ESP32(Serial2, RX, TX);<\/code><\/pre>\n\n\n\n<p class=\"rntbox rntclgreen\">Recommended reading: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-uart-communication-serial-arduino\/\">ESP32 UART Communication (Serial): Set Pins, Interfaces, Send and Receive Data (Arduino IDE)<\/a>.<\/p>\n\n\n\n<p>Enable the Serial communication and MP3 debugging, so you can see the hex serial commands being sent to the device. With debugging enabled, you will also see helpful errors.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);\nmp3.enableDebugging();<\/code><\/pre>\n\n\n\n<p>You can quickly play the first track stored on the microSD Card using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>mp3.playTrack(1);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>Upload the previous code to your ESP32 board. It will play the first track stored in the microSD card. Your serial monitor should be printing a similar message:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"746\" height=\"416\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-playback-track-Arduino-IDE-Serial-Monitor-Demonstration.png?resize=746%2C416&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 YX5300 YX6300 MP3 Player playback track Arduino IDE Serial Monitor Demonstration\" class=\"wp-image-189965\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-playback-track-Arduino-IDE-Serial-Monitor-Demonstration.png?w=746&amp;quality=100&amp;strip=all&amp;ssl=1 746w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-YX5300-YX6300-MP3-Player-playback-track-Arduino-IDE-Serial-Monitor-Demonstration.png?resize=300%2C167&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/figure><\/div>\n\n\n<p>If you have the headphones or speaker plugged into the headphone jack, you should be hearing the first track stored in your microSD card.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Connected-to-Headphone-Speaker-Jack.JPG.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"YX5300 YX6300 MP3 Player Serial Module Connected to Headphone Speaker Jack\" class=\"wp-image-189802\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Connected-to-Headphone-Speaker-Jack.JPG.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/YX5300-YX6300-MP3-Player-Serial-Module-Connected-to-Headphone-Speaker-Jack.JPG.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>If you are experiencing issues with this project, follow the next troubleshooting section.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"troubleshooting\">Troubleshooting the YX5300\/YX6300 MP3 Player Module<\/h2>\n\n\n\n<p>If you uploaded the previous code, but you can&#8217;t hear any sound with the YX5300\/YX6300 MP3 Player Module it can be one of these following issues.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Wiring error:<\/strong> in all projects that use serial commands, you need to connect the pins TX-RX and the RX-TX. However, if the code is not running properly (not sending\/receiving serial commands), you might need to swap the wiring and connect RX-RX and TX-TX. One of our Serial MP3 players came with the wrong labels on the module, and the only way it worked was connected with TX-TX and RX-RX;<\/li>\n\n\n\n<li><strong>Not enough power: <\/strong>according to the product specifications in the manual, the VCC is works with voltages between 3.2V-5.2V. According to our testing, it works most reliably when connected to 5V (VIN);<\/li>\n\n\n\n<li><strong>MicroSD card issue:<\/strong> your microSD must be equal or less than 32GB and formated with FAT16 \/ FAT32. The track formats must be in an .mp3 \/ .wav files with 8-48 kHz frequencies;<\/li>\n\n\n\n<li><strong>Wrong folder structure \/ filenames:<\/strong> your microSD card folder and file structure is incorrect, example folder and filenames: <em>01\/001xxx.mp3 01\/002xxx.mp3 01\/003xxx.mp3 02\/004xxx.mp3<\/em>;<\/li>\n\n\n\n<li><strong>Issue headphones\/speaker:<\/strong> we recommend testing your headphones\/speakers in another device to make sure they are working.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>This was quick guide on how to play sounds with the YX5300\/YX6300 MP3 Player module with an ESP32 board. For an extended comprehensive guide on how to interface the YX5300\/YX6300, you can read this other guide:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-yx5300-yx6300-mp3-player-arduino\/\">ESP32 with YX5300\/YX6300 MP3 Player (Arduino IDE)<\/a><\/li>\n<\/ul>\n\n\n\n<p>We hope you&#8217;ve found this guide useful. We have other guides that might be helpful:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-apds9960-sensor-arduino\/\">ESP32 with APDS9960 Proximity, Light, RGB, and Gesture Sensor<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/cheap-yellow-display-esp32-2432s028r\/\">Getting Started with ESP32 Cheap Yellow Display Board<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-guides-sensors-modules\/\">ESP32: Free Guides for Sensors and Modules<\/a><\/li>\n<\/ul>\n\n\n\n<p>To learn more about the ESP32, make sure to check out our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (eBook)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">All our ESP32 Projects and Guides<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to play .mp3 or .wav audio files stored on microSD card using an ESP32. We&#8217;ll be using the YX5300 \/ YX6300 Serial MP3 Music Player Module wired to &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32: Play Sound or Audio .mp3\/.wav Files using YX5300 (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-play-audio-mp3-wav-arduino\/#more-189809\" aria-label=\"Read more about ESP32: Play Sound or Audio .mp3\/.wav Files using YX5300 (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":189807,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,299,264],"tags":[],"class_list":["post-189809","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2026\/02\/ESP32-Guide-YX5300-YX6300-MP3-Player-Module-Play-Sound-Arduino-IDE.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/189809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=189809"}],"version-history":[{"count":3,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/189809\/revisions"}],"predecessor-version":[{"id":190953,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/189809\/revisions\/190953"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/189807"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=189809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=189809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=189809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}