This is an old revision of the document!
Portable MP3 Player
Introduction
The project consists of creating a portable MP3 Player capable of playing audio files from a microSD card and displaying current track information on an OLED screen. Music is listened to through headphones connected to the auxiliary output.
Utility: For me, it represents an opportunity to learn the integration of communication protocols (I2C, Serial) and power management (Li-Po battery). It is also a way to listen to music using a device I created myself. For others, maybe a cool toy :) that is an example of an embedded system balanced between dedicated hardware resources and software control.
General Description
The project integrates the following hardware modules:
Arduino Nano (ATmega328P): The “brain” of the system that processes button inputs and commands the peripherals.
DFPlayer Mini: The module responsible for reading files from the microSD card and playing the sound.
OLED Screen (I2C): Displays the player status and the menu.
Power System: 3.7V Li-Po battery with a TP4056 charging module and protection.
Block design:
Interaction: The user presses the buttons (Input), the Arduino processes the command (Software Logic), sends instructions via UART to the DFPlayer (Sound Output), and updates the screen via I2C (Visual Output).
Hardware Design
Hypothesis
“We believe that using a dedicated hardware decoding module (DFPlayer) will improve audio system performance because it offloads the ATmega328P microcontroller from the intensive task of processing the MP3 data stream, allowing for a smooth visual interface on the OLED screen.”
Components
1x Arduino Nano (Atmega328P)
1x DFPlayer Mini Module
1x OLED Module (I2C)
1x TP4056 Module (Li-Po Charger)
1x 3.7V 1200mAh Li-Po Battery
1x 3.5mm Audio Jack Module
3x Push buttons (Next/Vol+, Play/Pause, Prev/Vol-)
1x Toggle Switch (On/Off)
1x 1kOhm Resistor (for UART RX line protection)
1x Prototype PCB board & Jumping cables
Schematics
The electrical schematic was designed in KiCad, ensuring a modular and portable design.
Hardware Details:
Power: Managed by the TP4056 module. The battery provides ~3.7V, which powers the Arduino via the VIN pin.
Audio: DAC_R and DAC_L pins from DFPlayer are connected to the Audio Jack for stereo output.
Protection: A 1kOhm resistor is placed on the UART line between Nano (TX) and DFPlayer (RX) to prevent noise and protect the 3.3V logic of the player.
Pin Mapping
| Component | Arduino Pin | Connection Type |
| OLED Display | A4 (SDA), A5 (SCL) | I2C (Hardware TWI) |
| DFPlayer Mini | D8 (TX), D9 (RX) | UART (9600 bps) |
| Buttons | D2, D3, D4 | Digital Input (Interrupts) |
| Audio Jack | DAC_R, DAC_L, GND | Analog Audio |
| Power Switch | VIN | Power Control |
Exemplu de functionare:
Software Design
Description of the application code (firmware):
Development Environment: AVR / VS Code with PlatformIO.
Libraries and 3rd-party sources:
Using the standard `avr/io.h` library for register access.
Custom implementation for I2C (OLED) and UART (DFPlayer) protocols.
`util/delay.h` for timing.
Algorithms and Structures:
State Machine: To manage player states (Play, Pause, Stop, Next).
UART Protocol: Implementation of `UART_init` and `UART_transmit` functions to control the DFPlayer.
I2C Protocol (TWI): Managing the OLED screen by manipulating the TWI (Two Wire Interface) registers of the ATmega328P.
I have included concepts from the following laboratories:
Laboratory 3 (Interrupts): Used for control buttons (External Interrupts) to ensure minimal response time.
Laboratory 6 (UART): Asynchronous communication with the audio module (9600 bps).
Laboratory 7 (I2C/TWI): Control of the OLED screen via the I2C protocol, using the hardware TWI module of the microcontroller.
Results
Conclusions
Download
Journal
Bibliography/Resources