Introduction: Arduino Retro Style MP3 Player!
Mp3 player may sound quite outdated. Smartphones can do much better than this! With all those apps and streaming services, you don’t even need to download any music or song.
But when I encountered the DFplayer module it really excited me with a bunch of features. From volume control, a 3W amplifier, equalizer, ability to play ads between the mp3 files, and much more. I wanted to explore all these features and put them to good use in a single device. So this MP3 player was a perfect choice.
The end product was quite interesting to use with the following features:
- EQ Adjustment
- Volume Control
- Pause/play MP3 files
- 2 screen navigation
- rechargeable battery
Step 1: Setting Up the OLED Display
1.3-inch OLED and 0.96-inch OLED may look similar, but they don’ t share the same display driver, So if you try to use a library like Adafruit SSD1306, the display won't work because the 1.3inch OLED display has Sh1106 display driver.
So, we are going to use the U8g2 library. You can download this library for your Arduino IDE with this link or go to your library manager and install the latest version of U8g2.
This library has a lot of flexibility when compared to other libraries, for example, you can run the same code for a variety of displays with very minimal code change and importantly gives you a wide range of fonts and open icons to use in your project.
The 1.3-inch display has 4 pins VCC, GND, SDA, and SCL.
Since the display supports an I2C communication, connect the VCC and GND to +5V and GND of the Arduino pro mini and connect the SDA and SCL to A4 and A5 of the Arduino pro mini.
You can test the display either by running the demo sketch which comes with the u8g2 library or you can compile and run my sketch which is in Soundpod.rar file or use the Github link.
Step 2: Setting Up DFPlayer
DFplayer is a small and cheap MP3 module with a simplified output that can be directly connected to a speaker without an amplifier.
- 24bit DAC
- Supports FAT16, FAT32 file system
- Up to 32GB SD card support
- Built-in 3Watt Amplifier
- supports 100folders, each folder can support up to 1000songs
- 5 levels of EQ adjustment and 30 levels of volume adjustment
This module can be used standalone with an attached battery, speaker & push buttons or can be used with an Arduino or any other microcontroller. It uses UART/serial communication for sending and receiving commands to microcontrollers. So we can use the Arduino's serial read/write function to control this module.
Connect 4 push buttons to the pin 2,3,4 of the Arduino for controlling the volume/start/stop and then connect the pin Rx and Tx pin of the DFplayer to Arduino pin 10 and 11. Finally, connect the speaker to spk+, spk- of the DFplayer, and connect +5v supply to VCC and GND to GND of the DFplayer.
You can test your module with the code which is in the folder 'DFPlayer'. This instructable would help you more in easily getting started with Arduino and DFPlayer.
Step 3: Preparing the Components
You would have seen the final built looks messy and you may think it would be way better to print a PCB. I totally agree! But this is comparatively more fun and personally they are pretty cool to look at as well. Anyway, I will drop a link where you can use the existing circuit and build a PCB.
Since there are too many components to use, a 2 sided PCB would be a perfect fit. Then cut 2 sided PCB in such a way that horizontally it has 14 holes and vertically 21. Then placed the push buttons which will help us in navigation, pause, and play of the song. While placing other components you need to be really careful where you place them and how many pins each component has. From my experience of building this twice, keep only the pins that are used and cut the rest of them, It would solve more problems down the road. You can refer to this circuit diagram and cut the unnecessary pins.
Step 4: Placing the Components
Place the digital pins of the Arduino close to the buttons and the analog pins pointing toward the top of the board so it would be easy connecting to the OLED display. Then do the same process for the DFplayer, place the module in such a way that the SD card slot is pointed inward, and also remove the black separator from the header pins, so the DFplayer has a proper fit in the board along with the Arduino.
I wanted to run DFplayer with full capacity, so I added a small boost converter to convert the 3.7 volts from the lithium battery to 5V. But in the end, this module couldn’t provide enough current to run the DFPlayer. And I felt it was doing much better with the 3.7-volt battery alone So, in the end, I discarded the boost converter(the green PCB module next to the Arduino pro mini).
Finally, to finish it off the backside of the PCB install the slide switch and the 3.5mm audio jack.
Step 5: Soldering Everything Together
Follow the circuit diagram and solder the components close to each other, where you can merge two connections easily, and try to avoid using wires. Instead, use a bare single strand wire to make the connections and make sure you don’t touch any of the components on the bottom side too. And I Placed 2 single strand wires which are poking out of the board, this will be later used to solder the TP4056.
Step 6: More Soldering!
Place the TP4056 module, which we will be using to charge our MP3 player with micro-USB. I used double-sided tape to place the Lithium polymer battery next to the charging module. This is a 300Mah module that fits perfectly within the PCB. If you build a bigger one, You can easily expand the battery without any modification to the current circuit.
Finally, solder the OLED display to finish it off, If you could follow the circuit diagram and place the components in the same order it will be a lot easier to work with.
Step 7: Uploading the Code and Finishing Touches
Then I gave some final touch, by giving it some smooth rounded corner and I drilled a hole at the top corner so I can use this as a keychain!
Now, we can look into the programming part!
Instructions for the installation of the required libraries and how to use them is given in the Readme file on my git repository of this project. Just follow the instructions and use an FDTI module to program which is in the soundpod.rar file to Arduino pro mini. We are using an FDTI module because Arduino pro mini doesn't support USB to program it.
Finally, I removed the lights from the Arduino pro mini and DFplayer to save some battery and distraction it was causing while playing the song.
Step 8: Finished Project!
If you turn on the circuit after uploading the code, you can see Arduino boots up and the OLED screen works. Before jumping in and seeing all the features of this MP3 module, copy some music files to SD. For this, you have to follow some certain naming convention, where your folders should be named 01,02,..etc and your files inside each folder should be named 001,002,003..etc.
So to make everything simple I have a python script in the GitHub repo along with the code for this project. Just run the script in the command prompt and you should get a GUI interface where you can transfer files to your SD card hustle free for your DFPlayer.
Here you can create as many folders as you want, and you can add as many as files as you need in the files list. You can also remove unwanted folders and files (The program is designed to look like software from the past decade so it matches our mp3 build). Insert the SD card and turn on the soundpod(That's the name I gave for my MP3 player XD).
You can see the working of this soundpod in the video posted above!
Participated in the
First Time Author Contest