include | ||
lib | ||
src | ||
test | ||
.gitignore | ||
.travis.yml | ||
build_version.sh | ||
DEPLOY.md | ||
deploy.sh | ||
partitions.csv | ||
platformio.ini | ||
README.md |
ESMP3
What you need
Please note: This list is a "things I used", neither "these are the best things for this stuff" nor "you can only use these things". But please be aware that using other stuff may lead to you having to make more or less easy modifications.
Prizes are more or less the cheapest I could find on Aliexpress.
What? | For what? | Price (approx) |
---|---|---|
ESP-32-WROOM-32D | Controlling everything | 4€ |
WS1053B on a PCB with SD card slot | Play the MP3 files; provide an SD card slot | 5€ |
MFRC522 | RFID reader | 1€ |
5V Amplifier(s) (e.g. 2x PAM-8302) | Single-channel Amplifier | 2€ |
Speaker(s) matching your amp (e.g. 2pcs 4 Ohm 5W) | Enabling you to hear the sounds | 4€ |
RFID tags (ISO14443A) - e.g. 10 cards | You can also get Keyfobs or stickers | 4€ |
4 buttons | Prev/Next track, Volume up/down | 1€ |
You'all also need an SD card, some breadboard(s), jumper cables and a soldering iron. Also, some kind of box for the finished player.
How to connect
Schematics coming soon...ish...
How to install
Format your SD card with FAT32 and put files on it: Every album has to go into its own folder in the root of the SD card. Folders and files should not contain special characters (meaning stuff like äöüß). Spaces and dashes an alike are okay. Put the SD card into the SD card slot.
Copy include/config.sample.h
to include/config.h
. Modify it to at
least contain the correct login details for your WiFi.
The code then should compile in PlatformIO without errors. Upload it to your ESP32. After that, upload static files using PlatformIO's task "Upload file system image".
The serial console in PlatformIO should give you more or less useful messages about what's going on. There will also be a line saying "WiFi connected. IP address: xxx.xxx.xxx.xxx" when the connection to your WiFi succeeded.
In your browser, enter "http://xxx.xxx.xxx.xxx/" (using the IP address) from above. From there you can define mappings between RFID tag IDs and folders on the SD card.
RFID-folder-mappings
Via webinterface
To create a new mapping between an RFID tag and an folder, you can use the web interface. Click the button with the cogs icon. After putting your rfid tag on the reader (and possibly removing it again), its ID will be shown in the dialog. Click the button with the arrows behind the ID to start the mapping mode.
The dialog showing all folders with media files will be shown. Click the button with the arrows behind the correct folder, to create the mapping.
Manually
Mapping are stored on the SD card in the file /_mapping.txt
. Every
mapping goes on its own line. Lines should be separated by \n (Unix-
style line endings); the last line should also end with a newline.
Format of a line is <RFID id>=<folder>
. RFID id is the UID of an
RFID tag, expressed as 8 lowercase characters with leading 0 (if
necessary). Folder is the foldername to play; starting with a slash and
ending without one.
A valid _mapping.txt
could look like this:
1a2b3c4d=/Christmas Music Vol. 17
003aab7f=/Let it go
b691a22c=/Frozen Audiobook
22cb6ae9=/Let it go
(Yes, more than one tag can map to a folder.)
Technical details
Ports
Device | Port | Connected to |
---|---|---|
VS1053 | CS | 16 |
VS1053 | MISO | 19 |
VS1053 | MOSI | 23 |
VS1053 | SCK | 18 |
VS1053 | XCS | 4 |
VS1053 | XRESET | 0 |
VS1053 | XDCS | 2 |
VS1053 | DREQ | 15 |
RC522 | SDA | 17 |
RC522 | SCK | 18 |
RC522 | MOSI | 23 |
RC522 | MISO | 19 |
AMP_L | SD | 27 |
AMP_R | SD | 26 |
BTN_PREV | 22 | |
BTN_NEXT | 33 | |
BTN_VOL_UP | 21 | |
BTN_VOL_DOWN | 32 |
Buttons pull to GND if pushed -> Internal Pull-Up needed!
RFID tags
The mapping of rfid tags to files uses the ID of the
tag. A file called _mapping.txt
in the root folder of
the SD card defines the mappings between RFID tag ids and
folders to play.
The easiest way to create this file is to use the mapping functionality of the webinterface.
Special modes
You can also save data on the tags to further manipulate the system. Position of the data is irrelevant, the whole tag will be searched.
Using [random]
will play the files in a random order.
[random:2]
will randomize everything except the first 2
files. This can be useful for having the favorite song of
your kids playing, but after that getting a bit of randomness.
Using [lock]
will turn this key into a key for the locking
mode. Scanning the tag enables locking mode. The next album
started will keep running until the end. Removing the tag
will be deactivated, as are the buttons for prev and next
track. You can disable locking mode by again scanning the
lock tag again.
[advent]
is used for christmas time. An album with this tag
will only play in December. On December 1st, only track 1
will play. On December 2nd, track 2 followed by track 1. On
December 3rd, tracks 3, 1 and 2. From December 24th on, track
24 followed by tracks 1-23. So your kid will get the "daily track"
first, followed by all previous tags in the right order.
API
You can send commands to ESMP3 using three different ways:
- Through a websocket connection to
ws://<IP>/ws
. - Through the serial console using an USB cable.
- Via HTTP POST request to
http://<IP>/cmd
, having the command in the variablecmd
.
Supported commands are:
Command | Action |
---|---|
play <PATH> |
Starts playing the given path. Path may be a path on the |
sd card or a http(s) URL of a webstream (direct links to mp3/4/ogg streams, | |
PLS files, M3U files or podcast XML feeds are supported). | |
play |
Continues playing the previously played thing. |
stop |
Stops playing. |
volume=<X> |
Sets the volume to X (0-255). |
track_prev |
Starts the previous track, if available. |
track_next |
Starts the next track, if available. |
track=<X> |
Starts playing track no. X of the currently playing album. |
reset_vs1053 |
Resets the VS1053 audio chip. |
reboot |
Reboots ESMP3. |
add_mapping=<ID>=<PATH> |
Adds a mapping between RFID card and path |
. See play for valid path formats. |
|
update |
Runs an update check. |