Difference between revisions of "MP3 player"

From Let's Control It
Jump to navigation Jump to search
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
The ESP module can control the MP3-player module "DRPlayer DRF0299" and the "YX5300" module with 3.5mm output for speaker(s).
+
The ESP module can control the MP3-player module "DRPlayer Mini (DFR0299/YX5200)" and the "YX5300" module with 3.5mm output for speaker(s). Other than MP3 (sampling frequencies up to 48kHz) WAV files are also supported. The file names can be whatever but if you would like to be sure to play the correct file you should use the following name schema:
 +
 
 +
0001.mp3, 0002.mp3, 0003.mp3 ... 2999.mp3, 3000.mp3
 +
 
 +
 
 +
[[File:DFPlayer-Mini-MP3-Player.jpg|280px|YX5200]]
 +
[[File:YX5300-MP3-Player.jpg|420px|YX5300]]
  
 
== Hardware ==
 
== Hardware ==
Line 6: Line 12:
 
Circuit wiring:
 
Circuit wiring:
  
1st-GPIO -> ESP TX to module RX
+
    '''ESP'''            '''Mp3 board'''
  3.3-5V to module VCC (can be more than 100mA)
+
    GPIO    <-->   RX*
GND to module GND
+
   
  Speaker to module SPK_1 and SPK_2 (not to GND!)
+
    '''Power'''
  (optional) module BUSY to LED driver (low active)
+
    3.3V    <--VCC (can be >100mA)
 +
    GND     <-->  GND
 +
   
 +
    DRPlayer Mini setup below...
 +
 +
    '''Speaker'''
 +
    Red    <-->  SPK_1
 +
    Black  <-->  SPK_2
 +
 +
    '''LED'''
 +
    LED**  <-->  BUSY
 +
 +
*note that the TX on the mp3-module is not used!
 +
  **optional, if you want a LED to indicate playback (low active).
 +
 
 +
=== DRPlayer Mini Pinout ===
 +
 
 +
[[File:DFPlayer-Mini-MP3-Player PINS.jpg|520px]]
  
 
= ESP Easy =
 
= ESP Easy =
Line 18: Line 41:
  
 
Enter the GPIO pin for serial TX.
 
Enter the GPIO pin for serial TX.
 +
 +
== Example on how to play a track ==
 +
 +
'''HTTP'''
 +
 +
<pre style="color: #0077dd">
 +
http://<ESP IP address>/control?cmd=play,14
 +
</pre>
 +
This plays track number 14. The song will be stopped once completed.
 +
 +
----
 +
 +
'''Rules'''
 +
 +
You can also use these from rules. This example plays a track (255) on boot, with a given volume (10), plays it for a period (30s) and then stops.
 +
 +
<pre style="color: #0077dd">
 +
On System#Boot do
 +
  vol,10
 +
  play,255
 +
  delay,30 //play the song for 30 seconds (this is a generic command!)
 +
  stop
 +
endon
 +
</pre>
 +
 +
----
 +
 +
'''MQTT'''
 +
 +
Topic:
 +
<pre style="color: #0077dd">
 +
<unit name>/cmd
 +
</pre>
 +
 +
Payload/message:
 +
<pre style="color: #0077dd">
 +
play,188
 +
</pre>
 +
 +
This will play the song number 188.
  
 
= Commands =
 
= Commands =
  
play,<track>       Plays the n-th track 1...3000 on SD-card in root folder. The track number is the physical order - not the order displayed in file explorer!
+
 
stop               Stops actual playing sound
+
{| class="wikitable sortable"
vol,<volume>       Set volume level 1...30
+
|-
eq,<type>           Set the equalizer type 0=Normal, 1=Pop, 2=Rock, 3=Jazz, 4=classic, 5=Base (IS NOT SUPPORTED BY YX5300)
+
! Command
 +
! Value
 +
! Extra information
 +
|-
 +
 
 +
| play,<value>
 +
| '''1...3000'''
 +
| Plays the n-th track 1...3000 on SD-card in root folder. The track number is the physical order - not the order displayed in file explorer! (The track will be played once and then stopped.)
 +
|-
 +
 
 +
| stop
 +
| -
 +
| Stops actual playing sound.
 +
|-
 +
 
 +
| vol,<value>
 +
| '''1...30'''
 +
| Set volume level.
 +
|-
 +
 
 +
| eq,<value>
 +
| '''0...5'''
 +
| Set the equalizer type (IS NOT SUPPORTED BY YX5300)<br>0=Normal<br>1=Pop<br>2=Rock<br>3=Jazz<br>4=Classic<br>5=Base  
 +
|-
 +
|}

Latest revision as of 21:12, 15 December 2017

Introduction

The ESP module can control the MP3-player module "DRPlayer Mini (DFR0299/YX5200)" and the "YX5300" module with 3.5mm output for speaker(s). Other than MP3 (sampling frequencies up to 48kHz) WAV files are also supported. The file names can be whatever but if you would like to be sure to play the correct file you should use the following name schema:

0001.mp3, 0002.mp3, 0003.mp3 ... 2999.mp3, 3000.mp3


YX5200 YX5300

Hardware

Circuit wiring:

    ESP            Mp3 board
    GPIO    <-->   RX*

    Power
    3.3V    <-->   VCC (can be >100mA)
    GND     <-->   GND

    DRPlayer Mini setup below...

    Speaker
    Red     <-->   SPK_1
    Black   <-->   SPK_2

    LED
    LED**   <-->   BUSY

*note that the TX on the mp3-module is not used!
**optional, if you want a LED to indicate playback (low active).

DRPlayer Mini Pinout

DFPlayer-Mini-MP3-Player PINS.jpg

ESP Easy

Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks. Select "Notify - " from the dropdown box.

Mp3-device.PNG

Enter the GPIO pin for serial TX.

Example on how to play a track

HTTP

http://<ESP IP address>/control?cmd=play,14

This plays track number 14. The song will be stopped once completed.


Rules

You can also use these from rules. This example plays a track (255) on boot, with a given volume (10), plays it for a period (30s) and then stops.

 On System#Boot do 
   vol,10
   play,255
   delay,30 //play the song for 30 seconds (this is a generic command!)
   stop
 endon

MQTT

Topic:

 <unit name>/cmd

Payload/message:

 play,188

This will play the song number 188.

Commands

Command Value Extra information
play,<value> 1...3000 Plays the n-th track 1...3000 on SD-card in root folder. The track number is the physical order - not the order displayed in file explorer! (The track will be played once and then stopped.)
stop - Stops actual playing sound.
vol,<value> 1...30 Set volume level.
eq,<value> 0...5 Set the equalizer type (IS NOT SUPPORTED BY YX5300)
0=Normal
1=Pop
2=Rock
3=Jazz
4=Classic
5=Base