This is an mp3 audio player built from a esp8266 wifi module and a dfPlayer mp3 module. It plays files from a SD card.
I housed it in an old computer speaker and made it battery operated, but it could be built into any speaker enclosure.
Features include
The following parts are needed
These can all be sourced for very modest amounts on sites like eBay
Tools needed
The dfPlayer module can be tricky to mount as it needs to have external access to a slot for getting at the SD card. For enclosures that have a flat panel I have used a 3D printed bracket designed to hold the module securely up against the panel https://www.thingiverse.com/thing:2832993
The schematic is fairly simple.
A LIPO battery charge module is used to charge the battery.
The battery feeds the dfPlayer module directly and the ESP-12F via a 3.3V regulator.
The dfPlayer is controlled over a serial interface so 2 pins on the ESP-12F module support this.
4 push buttons are tied to the ESP-12F GPIO for standalone operation.
The speaker and headphone jack are directly supported by the dfPlayer module.
The details of the mechanical construction will vary with the type of enclosure to be used. The example here used computer speaker unit. This had plenty of room inside for the modules and electronics.
The picture shows the completed view for this example. The USB, power switch, and push buttons are on the right hand side. The LIPO is mounted on the back. The ESP-12F module, headphone jack and dfPlayer are mounted on the left hand side. The battery was mounted on the back.
The general steps after working out a layout that suits your enclosure are
Double check the power wiring!
The ESP software is written in the Arduino environment. Source code is available at https://github.com/roberttidey/dfPlayer The library that controls the dfPlayer is there. The other libraries required and listed there are standard modules.
The ino sketch does not need much changed although you will want to change the WifiManager and firmware update passwords.
Compile in a Arduino ESP8266 environment and do the first flash over the standard serial connection. Further updates can be done by exporting a binary file in the Arduino IDE and doing an OTA (over the air) update direct to the unit without any wires.
On first use the software will not have the local wifi credentials but instead will create an Access point itself called dfPlayerSet up. Connect to this (e.g. from a phone or tablet) and then browse to 102.168.4.1. This will bring up an interface to allow selection of the real network and enter its password. From then on this will be used automatically.
There is a simple file uploader which should be used to load basic files to the SPIFFS filing system on the ESP-12F (edit.htm.gz, index.html, basic.htm, favicon*.png and graphs.js.gz. Access this by using http://ip/upload
From then on you can use http://ip/edit to upload further data in a friendlier fashion.
You can edit the index.htm to refer to different favicon file and give it a different title if required.
The favicon will be used if adding a shortcut to the screen on say a phone.
The dfPlayer plays back files directly from the SD card but it has a limited folder and file naming scheme.
To make it easier to use and to control a script is provided with the software that can support this naming but also allow the original names to be sued on the web interface.
To use mount the SD card onto a PC and copy across folder with tracks with their original naming (e.g. albums for folders and tracknames for files).
Run the script (dfPlayer-makeSD.vbs). It will prompt for the SD card volume. Change this as necessary. It will then rename all the folders and files on the SD card and create mapping files from the simplified naming back to the original names. Folders.txt contains a list of the folder numbers and names. Individual Track.txt file contain the mapping within each folder. Only the Folders.txt is needed at this stage. Software enhancements may use the track lists in the future.
The Folders.txt file needs to be uploaded to the ESP-12F SPIFFS file system via the /edit uploader.
Note that you can delete folders and add new ones. When you add a new one with original naming just run the script again. It will rename just th enew folders and files and rebuild the maps. The new FOlders.txt would need to be uploaded again.
The 4 buttons work as follows.
This is accessed at http://ip (index.htm default)
It brings up a simple web interface with a volume slider and a set of play controls
Below this is a set of buttons one per folder on the card populated with their original names. Clicking on one of these will start playing that folder.
A simplified browser interface may be used primarily for test purposes. This is accessed at http://ip/basic.htm
It allows selection of the command and its parameters to send to the software.
These commands are sent to the ESP12-F using
http:/ip/dfPlayer?cmd=command&p1=first&p2=second&p3=third
The commands available are
http://ip/dfPlayerStatus gives some basic status of the player including battery voltage