Difference between revisions of "MP3 player"

From Let's Control It
Jump to navigation Jump to search
Line 23: Line 23:
 
== Example on how to play a track ==
 
== Example on how to play a track ==
  
HTTP
+
'''HTTP'''
 
<pre style="color: #0077dd">
 
<pre style="color: #0077dd">
 
http://<ESP IP address>/control?cmd=play,14
 
http://<ESP IP address>/control?cmd=play,14
Line 29: Line 29:
 
This plays track number 14. The song will be stopped once completed.
 
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 on boot, with a given volume, plays it for a period and then stops.
 
You can also use these from rules. This example plays a track on boot, with a given volume, plays it for a period and then stops.
  
Line 39: Line 41:
 
  endon
 
  endon
 
</pre>
 
</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 =

Revision as of 21:04, 19 July 2017

Introduction

The ESP module can control the MP3-player module "DRPlayer DRF0299" and the "YX5300" module with 3.5mm output for speaker(s).

YX5300

Hardware

Circuit wiring:

1st-GPIO -> ESP TX to module RX (Note that the TX on the mp3-module is not used!)
3.3-5V to module VCC (can be more than 100mA)
GND to module GND
Speaker to module SPK_1 and SPK_2 (not to GND!)
(optional) module BUSY to LED driver (low active)

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 on boot, with a given volume, plays it for a period and then stops.

 On System#Boot do 
   vol,10
   play,255
   delay,30 //play the song for 30 seconds
   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