Skip to main content
Version: FILS English

Automatic Music Player and Advertising System

An automated audio solution that blends background music with scheduled announcements using the RP2350 and Rust.

info

Author: Nedelcu Diana Ioana
GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-dianaioana05

Description

The project consists of an automated audio playback system. It plays a continuous playlist of WAV files from a microSD card. At predefined intervals (e.g., every 20 seconds), the system finishes the current song, switches to a folder for advertisements/announcements, plays one ad, and then returns to the music playlist. It also displays the current music/ad and the volume using an OLED screen.

Motivation

I chose this project because I wanted to build something practical that you see every day, like the audio systems in supermarkets or gyms that play background music and periodically interrupt it for announcements or ads.

Usually, these systems are either overpriced proprietary hardware or just a PC that’s overkill for the task. Using the RP2350 and Rust is a great way to try and build a "professional" version that is:

  • Reliable: It won't crash or stutter like a basic media player might.
  • Automatic: It handles the timing and switching between folders by itself, which is exactly how these systems work in the real world.

Architecture

The system follows a producer-consumer architecture managed by the Embassy executor:

  • Main Task (Producer): Reads raw WAV data from the MicroSD card via SPI.
  • I2S Driver (Consumer): Uses the Pico's PIO to stream the PCM data to the PCM5102A DAC. It uses DMA (Direct Memory Access) to ensure playback doesn't stutter while the CPU is busy reading from the SD card.
  • Timer Task: Tracks the 20 second intervals and signals the main task to switch directories.
  • User Interface: Handles GPIO interrupts from push buttons for volume adjustment.
  • OLED Screen: Displays the current song or ad and the current volume using the I2C protocol and reading the file names from the MicroSD card.

Design


Log

Week 5 - 11 May

  • Established project topic and finalized the hardware list.

Week 12 - 18 May

  • Decided to switch from MP3 to WAV to focus on high-throughput data handling.

Week 19 - 25 May

  • Ordered components.

Week 27 July - 02 August

  • Ordered the OLED screen and implemented it

Weeks 3 - 21 August

  • Recreated the software and hardware from scratch

Hardware

The project uses the Raspberry Pi Pico 2W (RP2350), which provides more processing power for audio handling. The PCM5102A DAC provides high-quality stereo output via an I2S interface. It also contains a microSD card reader connected to the Pico with an SPI protocol, an OLED screen (0.91 inch) that uses the I2C protocol and 2 buttons for volume up/down and a status LED that use GPIO.

Physical Setup

Hardware Setup

Schematics

Kicad Schematic

Software Data Flow

  1. File System Task: Reads raw WAV data chunks from the SD card into a shared memory buffer.
  2. Audio Task: Consumes the buffer and uses DMA to stream data to the PIO state machine, ensuring the I2S timing remains perfect.
  3. Manager Task: An async loop that tracks the 20 second timer for advertisements and handles button interrupts to change the playback state.
  4. Display Task: In order not to overload the memory and keep the sound quality, I decided to use a boolean variable that decides when the OLED needs to update.

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2WMain Microcontroller (RP2350)39.66 lei
PCM5102A Audio DACI2S Audio Output94.99 lei
MicroSD Card ModuleStorage Interface24.39 lei
Push ButtonsVolume/Skip Controls3.60 lei (10pcs)
Resistor setPull-ups and protection7.00 lei
OLEDDisplaying information20 lei
LEDStatus0.1 lei
WiresConnections5 lei
Lego caseDesign30 lei
BreadboardsConnections10 lei

Software

LibraryDescriptionUsage
embassy-rpHAL for RP2040 / RP2350Controls chip pins, SPI, I2C, and I2S audio
embassy-executorAsync ExecutorRuns the main async loop
embassy-futuresAsync UtilitiesPlays audio and reads files at the same time
embassy-timeTime DriverHandles delays and button debounce timers
embedded-sdmmcFAT File SystemReads music and ad files from the SD card
embedded-hal-busSPI Bus SharingConnects the SD card to the SPI bus
ssd1306OLED Display DriverControls the OLED screen
embedded-graphics2D Graphics EngineDraws text and UI on the screen
heaplessFixed-size CollectionsStores playlist lists and text strings
panic-haltPanic HandlerStops the chip safely if code crashes

  1. Modul OLED Albastru 0.91'' 128x32 I2C (Optimus Digital)
  2. Modul DAC Audio Stereo PCM5102A (Optimus Digital)
  3. Raspberry Pi Pico Series Documentation