Raspberry Pi Pico - Mini Mp3 Player Module
The Raspberry Pi Pico is a low-cost, high-performance microcontroller board built on the RP2040 chip. Paired with MicroPython and the DIYables Mini Mp3 Player module, you can easily build audio projects like alarm clocks, sound effect boards, or interactive displays.
This tutorial walks you through:
- Connecting the Mini Mp3 Player to a Raspberry Pi Pico — directly, without a resistor.
- Loading mp3 files onto the SD card correctly.
- Playing, pausing, resuming, stopping, and skipping tracks.
- Adjusting volume with physical buttons.
- Repeating tracks, shuffling, and organizing audio into folders.
- Monitoring playback status from your code.

Components Needed
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
No resistor required. The Raspberry Pi Pico operates at 3.3V — the same voltage the Mini Mp3 Player's UART expects.
The Mini Mp3 Player Module
The DIYables Mini Mp3 Player is a small, affordable audio module powered by the YX5200-24SS chip. It decodes mp3 audio from a micro SD card and can drive a speaker directly through its onboard 3W amplifier, or output line-level audio via DAC pins for use with an external amplifier.
The Raspberry Pi Pico talks to this module over UART at 9600 baud. Since the Pico has two hardware UART peripherals (UART0 and UART1), you can assign one entirely to the mp3 player while the other remains available for sensors or other serial devices.
Available serial commands include:
- Playback: play, pause, resume, stop, skip forward, skip backward
- Volume: 31 discrete levels from silent (0) to full blast (30)
- Equalizer: choose from Normal, Pop, Rock, Jazz, Classic, or Bass presets
- Looping: repeat one track, repeat a folder, repeat all, or enable shuffle mode
- Folder access: play tracks organized in numbered directories on the SD card
- Announcements: temporarily interrupt music with an advertisement track, then auto-resume
- Queries: ask the module for its current track, volume, EQ, and file statistics
Pin Description
| Pin | Purpose | Pico Connection |
|---|---|---|
| VCC | 3.2V to 5.0V power input | Connect to Pico 3V3(OUT) |
| GND | Ground | Connect to Pico GND |
| RX | Serial data input | Connect to Pico GPIO4 (TX, UART1) |
| TX | Serial data output | Connect to Pico GPIO5 (RX, UART1) |
| SPK_1 | Speaker + (built-in amp, 3W max) | Connect to speaker |
| SPK_2 | Speaker − | Connect to speaker |
| DAC_R | Right channel line output | Optional — for external amp |
| DAC_L | Left channel line output | Optional — for external amp |
| BUSY | LOW = playing, HIGH = stopped | Optional — read with GPIO |
| IO_1 | Short press → prev; long press → vol down | Not used (controlled via UART) |
| IO_2 | Short press → next; long press → vol up | Not used (controlled via UART) |

Wiring
The Raspberry Pi Pico uses 3.3V logic natively, so you wire the serial lines directly — no level shifting or resistors needed.
We recommend using UART1 on GPIO4 (TX) and GPIO5 (RX):
| Mini Mp3 Player | Raspberry Pi Pico | Notes |
|---|---|---|
| VCC | 3V3(OUT) | 3.3V output pin |
| GND | GND | |
| RX | GPIO4 (TX - UART1) | Direct connection |
| TX | GPIO5 (RX - UART1) | Direct connection |
| SPK_1 | Speaker + | |
| SPK_2 | Speaker − |

This image is created using Fritzing. Click to enlarge image
Tip: You can also use UART0 on different GPIO pins. The Pico's UART pins are flexible:
Getting the SD Card Ready
Prepare the micro SD card on your computer before connecting anything to the Pico:
- Format the card as FAT16 or FAT32 using your OS’s disk formatter.
- Add mp3 files to the root of the card. Name them with 3-digit zero-padded numbers:
- For folder-based playback, create 2-digit numbered directories containing 3-digit numbered files:
Important details for Raspberry Pi Pico users:
- Numbering starts at 1 (track 0 does not exist).
- The module orders tracks by the copy sequence, not alphabetically. Format the card, then copy each file individually in the desired order.
- Supported folder range: 01 through 99. Track range inside folders: 001 through 255.
- Slide the SD card into the module’s slot before plugging the Pico into USB power.
Detailed Instructions
Here's instructions on how to set up and run your MicroPython code on the Raspberry Pi Pico using Thonny IDE:
- Make sure Thonny IDE is installed on your computer.
- Confirm that MicroPython firmware is loaded on your Raspberry Pi Pico board.
- If this is your first time using a Raspberry Pi Pico with MicroPython, check out the Raspberry Pi Pico MicroPython Getting Started guide for step-by-step instructions.
- Connect the Raspberry Pi Pico board to the Mini Mp3 Player module according to the provided diagram.
- Connect the Raspberry Pi Pico board to your computer with a USB cable.
- Open Thonny IDE on your computer.
- In Thonny IDE, go to Tools Options.
- Under the Interpreter tab, choose MicroPython (Raspberry Pi Pico) from the dropdown menu.
- Make sure the correct port is selected. Thonny IDE usually detects it automatically, but you might need to select it manually (like COM12 on Windows or /dev/ttyACM0 on Linux).
- Navigate to the Tools Manage packages on the Thonny IDE.
- Search "DIYables-MicroPython-MiniMp3", then find the Mini Mp3 Player library created by DIYables.
- Click on DIYables-MicroPython-MiniMp3, then click Install button to install the Mini Mp3 Player library.

- Copy the provided MicroPython code and paste it into Thonny's editor.
- Save the code to your Raspberry Pi Pico by:
- Clicking the Save button or pressing Ctrl+S.
- In the save dialog, choose MicroPython device.
- Name the file main.py.
- Click the green Run button (or press F5) to execute the script.
- Insert the SD card with mp3 files into the Mini Mp3 Player module.
- Listen for audio playback through the connected speaker.
Starter Code Template
Raspberry Pi Pico Code — Play a Track
Try It
- Load the SD card, wire the module, connect the Pico via USB.
- Upload the code using Thonny IDE or your preferred MicroPython tool.
Playback Control
Every playback command is non-blocking. The Pico sends a 10-byte packet over UART1 and returns instantly, so your main loop continues running without delay.
| Method | What Happens | Code Example |
|---|---|---|
| play(n) | Start playing track n from the root folder | mp3.play(1) |
| play_next() | Skip to the next track in sequence | mp3.play_next() |
| play_previous() | Return to the previous track | mp3.play_previous() |
| pause() | Pause at the current position | mp3.pause() |
| resume() | Continue playing from the paused position | mp3.resume() |
| stop() | Halt playback completely | mp3.stop() |
Raspberry Pi Pico Code — Multiple Tracks
Raspberry Pi Pico Code — Next/Previous
Raspberry Pi Pico Code — Pause/Resume
Raspberry Pi Pico Code — Loop a Track
Repeat & Shuffle
Once you send a loop or shuffle command, the mp3 module handles continuous playback autonomously. The Pico is free to do other work — read sensors, update a display, or sleep to save power.
| Method | Behavior | Example |
|---|---|---|
| loop_track(n) | Continuously repeat a single track | mp3.loop_track(1) |
| loop_folder(f) | Play all tracks in folder f on repeat | mp3.loop_folder(1) |
| loop_all() | Cycle through every track on the card | mp3.loop_all() |
| stop_loop() | Finish the current track, then stop | mp3.stop_loop() |
| shuffle() | Random playback order across all tracks | mp3.shuffle() |
Raspberry Pi Pico Code — Folder Playback
Folder API
Organizing mp3 files into folders is ideal for Pico projects that need distinct audio banks — such as a multilingual doorbell, a quiz game with different question sets, or categorized sound effects.
| Method | Description | Example |
|---|---|---|
| play_folder(f, t) | Play track t in folder f (folders 01–99, tracks 001–255) | mp3.play_folder(1, 1) |
| play_large_folder(f, t) | Large-folder mode (folders 01–15, tracks 0001–3000) | mp3.play_large_folder(1, 2000) |
| play_from_mp3_folder(t) | Play from the dedicated /mp3 folder (tracks 0001–9999) | mp3.play_from_mp3_folder(1) |
Raspberry Pi Pico Code — Serial Console Control
| Command | Effect |
|---|---|
| 1–9 | Play track |
| + / − | Volume |
| p / r / s | Pause / Resume / Stop |
| n / b | Next / Previous |
| ? | Status |
Equalizer Options
Six built-in DSP presets shape the audio output. You can change the EQ at any time, even during playback. On Pico-based projects with small speakers, the Bass preset often sounds best.
| Constant | ID | Sound Profile |
|---|---|---|
| EQ_NORMAL | 0 | No EQ applied — flat frequency response |
| EQ_POP | 1 | Emphasizes vocals and high frequencies |
| EQ_ROCK | 2 | Boosted mids and lows for energy |
| EQ_JAZZ | 3 | Smooth, warm midrange tone |
| EQ_CLASSIC | 4 | Even balance across the spectrum |
| EQ_BASS | 5 | Strong low-frequency boost |
Checking Module Status
Query functions send a request over UART1 and wait for a response. They block the Pico for up to 100 ms (adjustable via set_timeout()). A return value of −1 means the module didn’t respond in time.
These are handy for building a Pico-based mp3 player UI — for example, showing the current track number on an OLED display.
| Function | Return | Description |
|---|---|---|
| is_playing() | bool | True when audio is actively playing |
| get_volume() | int | Volume setting from 0 to 30 |
| get_eq() | int | Active equalizer mode (0–5) |
| get_track_count() | int | How many tracks are on the SD card |
| get_current_track() | int | Which track number is playing right now |
| get_folder_count() | int | How many folders exist on the SD card |
| get_track_count_in_folder(f) | int | How many tracks are inside folder f |