ESP32 Projects

ESP32 MP3 Player + Online Radio + Snake Game! SquareLine Studio + LVGL

Discover how to build a full-featured ESP32 project with MP3 playback, internet radio, and games-all controlled with a stylish touchscreen interface.

Last Updated on August 6, 2025 by Engr. Shahzada Fahad

ESP32 MP3 Player:

ESP32 MP3 Player + Online Radio + Snake Game! SquareLine Studio + LVGL – Have you ever wondered how to build your own MP3 player or even a snake game; all using just one board?

An ESP32 MP3 Player, Online Radio & Snake Game project on the MaTouch ESP32-S3 Parallel TFT, with a SquareLine Studio LVGL GUI.

What I am about to show you will take your ESP32 projects to the next level!

This is the second article in our series on the MaTouch ESP32-S3 Parallel TFT with Touch 5” display.

In the first article, we explored the technical specs, discussed all the onboard interfaces, and went through the setup of the LVGL graphics library. But in that article, I didn’t cover the sound playback, and I received so many messages asking how to play MP3 files.

So today… we are doing exactly that!




In the first example, we will learn how to play MP3 files stored on a microSD card using the ESP32-S3. We will create a simple MP3 player; with Play, Stop, Next, and Previous buttons right on the display.

SquareLine Studio & LVGL interface for an ESP32 MP3 Player, Radio & Snake Game, shown on a MaTouch ESP32-S3 Parallel TFT.

We also display the song name at the bottom. This is a basic project; but it’s super useful for beginners, especially for students and hobbyists who want to learn how to play sound files from SD card.

The goal of this project is simple; teach boys and girls how sound playback works on ESP32-S3, with real hardware and an interactive UI.

In the second example, we make it even better.

We use a dropdown list to show all the available MP3 files on the SD card.

Dropdown list on a MaTouch ESP32-S3 for an MP3 player, Radio & Snake Game project. Made with SquareLine Studio & LVGL.

You just select a file, and it plays immediately! You don’t need Next or Previous buttons. You can also adjust the volume with a slider and stop the song anytime.

The selected song name is shown clearly at the top. This is a clean and easy-to-use interface, perfect for learning UI design and SD card integration.



In the third example, we do online streaming by accessing real Internet radio stations.

Yes, we stream songs directly from the internet using WiFi; no SD card needed!

The Online Radio feature of an ESP32 MP3 Player & Snake Game project on a MaTouch ESP32-S3, built with SquareLine Studio LVGL.

The UI is similar to the second example; but this time, I have added a beautiful background image to make it look futuristic. You can design your own background skins; and it makes a big difference in how your player looks.

I have explained this background image technique before in my smartwatch articles; so you already know how powerful that is.

Finally; just to make things fun; we create a Snake Game!

An ESP32 MP3 Player, Radio & Snake Game project on a MaTouch ESP32-S3 TFT, showing the game screen made with SquareLine Studio LVGL.



This one uses buttons on the right side to control the snake’s movement; up, down, left, and right.

You can also pause the game, stop it, and even see the score right on the screen.

The gameplay area is clearly separated with a line, so your buttons never get in the way.

It’s a super fun project and it shows just how flexible the ESP32-S3 with this display can be.

Now, why should you watch this full video and try these 4 examples?

Because once you do, you will have mastered audio playback, UI control, dropdown selection, internet streaming, and game logic; all in one powerful ESP32 project.

Whether you are a student, hobbyist, or even a teacher; this video gives you everything you need to build your own media devices and interactive UIs.

And trust me, it wasn’t easy.

The hardest part of this entire project was finding the correct audio library for playing sound.

There are so many libraries on GitHub; but most of them don’t work or are outdated.

I had to spend hours testing different libraries, just to find the right one that supports both SD card and internet streaming.

But the good news is; I have done all that for you, and now you can just follow along and make it work on the first try.

And let me tell you, you can download all the codes and resources from my Patreon page.

Before we get into the MP3 player and online streaming examples, let’s first talk about how the sound is actually played on this board.

The MaTouch ESP32-S3 MP3 Player, Radio & Snake Game LVGL project uses a MAX98357A I2S amplifier for audio output.

This display has a built-in I2S digital audio amplifier, the MAX98357A.

The MAX98357A is a small and powerful digital-to-analog audio converter. It takes I2S audio data from the ESP32 and converts it into clear analog audio, which you can hear through a speaker.

So, even if you don’t use this exact MaTouch display, you can still build your own audio projects using the MAX98357A breakout board. You can find these tiny modules online; very cheap; and they work perfectly with any ESP32 board.

Simply connect it to the I2S pins of your ESP32, load the code, and you can play MP3 files from SD card or even stream audio online. It’s that simple.

Now listen carefully; because this is very important.

To play MP3 files from the SD card, or to stream online radio stations, you must use the correct audio library. I spent hours searching on GitHub, trying different libraries… and most of them didn’t work. Either they didn’t compile, or they didn’t support I2S audio properly.

Finally, I found the right one and this is what I am using in all the examples.

ESP32_audioI2S_master-2.0.0

Now let me show you how to install the library step-by-step.

While your Arduino IDE is open, go to the top menu and click on:

Sketch → Include Library → Add .ZIP Library

A file browser will open.

Now, browse to the location where you downloaded the library ZIP file.

Using the ESP32-audioI2S library for audio in a MaTouch ESP32-S3 MP3 Player, Radio & Snake Game LVGL project by SquareLine Studio.

Select the zip folder, and click the Open button.

If the library is not already installed, Arduino will add it automatically to your libraries.

But in my case, I have already installed this library, so I am just going to click on the No button to skip it.



Example 1: Basic ESP32 MP3 Player from an SD Card

MP3 Player UI – Built with SquareLine Studio:

A MaTouch ESP32-S3 Parallel TFT project with an MP3 Player, Radio & Snake Game, showing its UI design from SquareLine Studio LVGL.

As you can see, I have designed a very simple MP3 Player UI – it’s made using just 4 buttons and 1 label.

This is kept intentionally simple so that beginners can easily follow along and start playing sound files without any confusion.

Now, if you want to create more advanced and stylish UIs, I have already made many tutorials on SquareLine Studio – so feel free to watch those videos if you are interested in leveling up your UI design skills.

The label simply displays the file name of the currently playing song.

Now let’s talk about the 4 buttons.

I have assigned an event to each button in SquareLine Studio:

If I click on the Stop button and go to the Inspector tab, then scroll down —

You will see I have added an event. The trigger type is set to RELEASED, and the function name is StopFun.

An ESP32 MP3 Player project on the MaTouch ESP32-S3 Parallel TFT, showing the UI created with SquareLine Studio and LVGL.

So, whenever the stop button is pressed, this function will be called in the code.

Don’t forget to check the “Do not export” checkbox, so SquareLine Studio doesn’t auto-generate any default code for it.

Next Button:

It calls the NextFun() function.

Play Button:

It calls the PlayFun() function.

Previous Button:

It calls the PreviousFun() function.

This makes the UI fully functional, and with just these four buttons, we have a working MP3 player that can play, stop, and switch between songs; and also show the song name.

Next, you need to download the following code, or if you want the complete package including the SquareLine Studio project, UI assets, and all necessary resources, you can download the full project folder from my Patreon page. This makes it super easy for you to get started; no need to set up everything from scratch. Anyways, let’s upload this code.

And one more thing, make sure to save the following code with the name touch.h in the same folder where your Arduino.ino file is located.




touch code:

Basic ESP32 MP3 Player Code:



Example 2: Upgrading with a Dropdown Song List

In this second example, I have simplified the MP3 player UI to keep things clean and beginner-friendly. Instead of using Play, Next, and Previous buttons like before, I have added a dropdown list that automatically loads all the .mp3 files from the SD card.

Dropdown list on a MaTouch ESP32-S3 for an MP3 player, Radio & Snake Game project. Made with SquareLine Studio & LVGL.

You can simply select any song from the list, and it will start playing instantly. At the top of the display, there’s a label that shows the name of the currently playing file. There’s also a Stop button to stop playback, and a volume slider to adjust the sound level in real-time. This time, I didn’t assign events from SquareLine Studio; all interactions are handled directly through code, giving you more flexibility and control.

ESP32 MP3 Player with Dropdown List – Code:



Example 3: Streaming Music with an ESP32 Online Radio

In this 3rd example, we move from playing local files to streaming music from online radio stations. The UI remains the same; simple and user-friendly; with the dropdown now listing all the available radio channels instead of .mp3 files.

Streaming online music on a MaTouch ESP32-S3 TFT from an ESP32 MP3 Player, Radio & Snake Game project with a SquareLine Studio LVGL UI.

The big visual change is the background image, which instantly gives the UI a more polished and futuristic look. If you want to take it even further and add animations, I have already covered this in my analog watch tutorials, where I explained how to animate PNG images; just like the moving clock hands you are seeing now. So with just a few tweaks, you can turn this radio into a professional-looking media player.



ESP32 S3 Streaming Online Radio Stations Code:




Example 4: Creating a Snake Game with Arduino GFX

This 4th example is about creating a simple but fun Snake Game—and this time, we are not using SquareLine Studio or even the LVGL library.

Snake Game Code:

The purpose of this example is to show you that it’s not always necessary to use heavy GUI libraries to build interactive projects. Sometimes, you can achieve great results with just basic graphics and smart coding.

Programming the Snake Game for a MaTouch ESP32-S3 TFT. Part of an ESP32 MP3 Player & Radio project with SquareLine Studio LVGL.

By manually drawing everything on the screen and using touch buttons for controlling the snake, we have created a fully functional game that’s fast and responsive. I also added pause and stop buttons, a score counter, and ensured the game behaves nicely even when the snake hits the screen edge—it wraps around to the other side.

So, that’s all for now.



Watch Video Tutorial:

 


Discover more from Electronic Clinic

Subscribe to get the latest posts sent to your email.

Engr. Shahzada Fahad

Engr. Shahzada Fahad is an Electrical Engineer with over 15 years of hands-on experience in electronics design, programming, and PCB development. He specializes in microcontrollers (Arduino, ESP32, STM32, Raspberry Pi), robotics, and IoT systems. He is the founder and lead author at Electronic Clinic, dedicated to sharing practical knowledge.

Related Articles

Leave a Reply

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

Back to top button

Discover more from Electronic Clinic

Subscribe now to keep reading and get access to the full archive.

Continue reading

Electronic Clinic
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.