Hello dear fellas,
I have a devkit Esp32 and I want to play some mp3 with YX5300 device.
I have connected YX5300 to 3,3v (try also 5v) and to 16-17 pin for tx/rx. I use a 8 gig microsd formatted as FAT32 and created two folders 01 and 02 and inside of each some mp3 or wav file with name that begin with 001-, 002- and so on. I tried also 16gig microsd.
I attach my earset to the device, but I cannot listen anything. Led on board is always red (not good sign), when it should be green if it plays.
Here below my very simple code:
#include <Arduino.h>
#include <MD_YX5300.h>
#include <SoftwareSerial.h>
const uint8_t esp32_RX = 16; // connect to TX of MP3 Player module
const uint8_t esp32_TX = 17; // connect to RX of MP3 Player module
SoftwareSerial MP3Stream(esp32_RX, esp32_TX);
MD_YX5300 mp3(MP3Stream);
bool playerPause = true;
void setup()
{
Serial.begin(115200);
Serial.println("Start setup");
MP3Stream.begin(MD_YX5300::SERIAL_BPS);
mp3.begin();
mp3.setSynchronous(true);
mp3.volumeMax();
Serial.println("End setup");
}
void loop()
{
mp3.check();
if (playerPause)
{
mp3.playFolderRepeat(2);
playerPause = false;
Serial.println("Playing");
}
} ```
Where am I wrong?
this opens ESP32 hardware port Serial2 on pins 15 and 16
// ESP32 serial2 hardware loop back test - jumper GPIO16 (Rx) and GPIO15 (Tx)
// see https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/
/* There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD.
*
* U0UXD is used to communicate with the ESP32 for programming and during reset/boot.
* U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though
* U2UXD is unused and can be used for your projects.
*/
#define RXD2 16
#define TXD2 15
void setup() {
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
Serial.begin(115200);
//Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
Serial.println("ESP32 hardware serial test on Serial2");
Serial.println("Serial Txd is on pin: "+String(TX));
Serial.println("Serial Rxd is on pin: "+String(RX));
Serial.println("Serial Txd is on pin: "+String(TXD2));
Serial.println("Serial Rxd is on pin: "+String(RXD2));
}
void loop() { //Choose Serial1 or Serial2 as required
while (Serial2.available()) {
Serial.print(char(Serial2.read()));
}
while (Serial.available()) {
Serial2.print(char(Serial.read()));
}
}