I have a number of projects where I needed to play sound and/or music through an internet connected device.
Whilst there are a number of ways to do this, my implementation was influenced by keeping the number of parts and cost to a minimum whilst not loosing overall flexibility.
HardwareI use the Wemos D1 Mini board that is based on the ESP-8266 WiFi micro controller and a CATALEX MP3 player that is based on YX5300 chip controlled via the UART using a serial protocol.
In my example implementation I have also added an amplifier, however this is optional and others are free to leave it out or chose an amplifier of their choice.
The ESP-8266 is flashed with the MicroPython firmware (I used the latest version 1.8 at the time of publishing). Note : My uPython code does not include the necessary instructions for configuring the WiFi aspect of the ESP-8266.
The uPython code is spread over three files.
yx5300.py, This is the python implementation of the serial protocol that the YX5300 chip uses. mp3.py
This is the library code to send the serial commands to the mp3 board.
main.py
The main application, HTTP Web Server that provides a very basic web UI to control the MP3 player through a browser.
The micro controller automatically starts the main.py script at startup. This script has a HTTP server that serves a simple web page to control the MP3 player through the ESP-8266. The current implementation does not make all the functionality available. >Copy all three files the the micro controller using either Ampy or the official MicroPython WebRepl utility.
WiringThe wiring between the two modules is pretty straight-forward. The MP3 module draws power from the ESP-8266 board. Make the following connections.
ESP <----> MP3
GND <----> GND
5V <-------> VCC
TX <-------> RX
RX <-------> TX
Connect power to the ESP-8266 board and everything should be working.
Comments
Please log in or sign up to comment.