The goal of this project was to replace the simple stand-alone MP3 player I used to play a playlist of soothing music in my daughter’s room at bedtime… with a remote controlled MP3 player that could play storybook MP3s as well as the good night music playlist.
I already had a couple of infrared remotes from a strip of LED lights that quit working–I needed a way to receive an IR remote’s commands, and trigger MP3s to play. I also had a small “Class-T” audio amplifier and speakers ready to plug into.
After googling around a little, I found this project on github that had a sketch for an Arduino to control an MP3 player. I bought this YX5300 MP3 player off Amazon for $8.
I had a package of three Arduino Nanos laying around, so when I got the YX5300 in I wired one of the up and uploaded the sketch. Fast forward through a lot of banging my head against the wall to finally determine that all three of the Nanos were bad. (Amazon of course refunded the money without question, which is why I buy all my cheap electronics from them.)
After striking out with the Nanos, I tried working with the and ESP32 device that I had laying around–the problem with this was that the IR library did not work with that device. I decided to switch to the ESP8266-based NodeMCU. Having using these before as part of temperature sensor and IR blaster projects, I felt a lot more confident about completing the project successfully. Although I meant to buy another unit of the same exact V2 device I’d used before, I accidentally bought the V3 model. The only apparent different is in the form factor: the V3 has a larger PCB. The only immediate downside of this was that I couldn’t use one of the cases I’d had 3D-printed at the local library — this didn’t matter in the end as I eventually found a much better project “box”.
I had a few IR receivers left over from the IR blaster project, so now my hardware had been gathered.
Early shot of wiring up the NodeMCU to the YX5300:
The MP3 player sketch I had found already had code to send hex commands to the YX5300 via serial and handle responses.
The YX5300 requires the MP3s to be loaded on an SD card following a specific naming convention: the folders must be named ’01’, ’02’, and so on, and the names of the MP3s inside those folders must start with ‘001’, ‘002’, etc.
The YX5300 has a bunch of commands you’d expect from an MP3 player:
- Play
- Pause
- Off/Reset
- Next Track
- Previous Track
There are also a few handy ways to play specific files:
- Play folder (e.g. play folder 01)
- Play specific track (e.g. play file starting with index 002 in folder 03)
These last commands allowed me to program the NodeMCU to play specific storybook MP3s upon receiving codes from the IR remote.
I re-used the IR Blaster project to capture all possible codes that the IR remote would send from its 24 buttons. This was trickier than I expected because the remote did not reliably send the same code upon pressing the same button. What the IR receiver parsed varied based on distance from the remote, and seemingly how many times the button was pressed. This generally meant that while I could define a certain code that corresponded to a certain button, I’d have the push the button several times before that code would be sent.
So I was able to code:
- 8 buttons for the storybooks
- 1 button to play all stories one after another
- 3 button for the music albums
- 1 button to play all music MP3s one after another
- 3 buttons for previous, next, and off
At this point, the program had come together, and was testing well with headphones. Next up I needed to find a good project box. My criteria were:
- Something fairly small so that it could fit on top of the bookcase with the power amplifier
- Something that the kids wouldn’t want to pull off the shelf and try to play with (e.g. a teddy bear or other toy)
I really didn’t have a good specific idea of what to use, when my buddy Max came up with a thrift store find that was perfect: a pink “MP3” speaker box. He helped me with ripping out the guts of the older speaker device, and mounting the NodeMCU and YX5300.
The speaker box had a battery compartment on the bottom–we were able to mount the YX5300 in such a way that the headphone jack lined up with hole for a headphone jack that was already there for the speaker, and the SD card slot could be reached by removing the compartment cover!
I used a dremel tool to cut a gash into the front face of the speaker box, and hot glued the IR receiver into the opening. (You can see where I got loose with the dremel tool and it took a chunk out of the pink plastic.) I covered the gash with an IR shield I yanked off the front of an old remote control.
Results:
- It works! And my daughter loves it!
- The process for adding a new MP3 to the kiddo blaster is pretty quick: rip a CD, copy the file to the kiddo blaster’s SD card with the right name, and the remote can trigger it straight away since I’ve programmed all the buttons ahead of time.
- We now use it regularly to listen to stories or music while winding down at bedtime.
Hardware:
Micro controller: NodeMCU v3 ESP-12E
Infrared receiver: CHQ1838
MP3 player: YX5300
Arduino sketch for NodeMCU: https://github.com/breakall/kiddo-blaster