So this is really Arduino adjacent ESP32 question:
I'm new to Arduino and ESP32, to please take that into account.
I am trying to control a Serial .MP3 player from my ESP32 (DIYables MP3 Player Module for Arduino, ESP32, ESP8266, Raspberry Pi).
To, for example,to play the first song on the SD card on the .MP3 module, it expects:
0x7E, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x01, 0xEF
I can send this from Arduino and the mp3 player works fine. When I try to send from ESP32 it doesn't.
I looked at the serial output from both Arduino and ESP32 and there is an extra null byte (0x0) in the serial transmission at the beginning of the Arduino output that is not in ESP32's send.
I’m also not sure why the ESP32 is sending 8-bit 0xEF as 32-bit 0xFFFFFFEF and 0xFF as 0xFFFFFFFF
The serial outputs looks like this:
Received from Arduino------------------Received from ESP32
Received: 0x0-------------------Received: 0x7E
Received: 0x7E-------------------Received: 0xFFFFFFFF
Received: 0xFF-------------------Received: 0x6
Received: 0x6------------------Received: 0x9
Received: 0x9------------------Received: 0x0
Received: 0x0------------------Received: 0x0
Received: 0x0------------------Received: 0x2
Received: 0x2------------------Received: 0xFFFFFFEF
Received: 0xEF------------------Received: 0x7E
Received: 0x7E------------------Received: 0xFFFFFFFF
Received: 0xFF------------------Received: 0x6
Received: 0x6------------------Received: 0x6
Received: 0x6------------------Received: 0x0
Received: 0x0------------------Received: 0x0
Received: 0x0------------------Received: 0x1E
Received: 0x1E------------------Received: 0xFFFFFFEF
Received: 0xEF------------------Received: 0x7E
Received: 0x7E------------------Received: 0xFFFFFFFF
Received: 0xFF------------------Received: 0x6
Received: 0x6------------------Received: 0x3
Received: 0x3------------------Received: 0x0
Received: 0x0------------------Received: 0x0
Received: 0x0------------------Received: 0x1
Received: 0x1------------------Received: 0xFFFFFFEF
Received: 0xEF ---------
The code I’m using is:
Arduino:
#include <SoftwareSerial.h>
#define ARDUINO_RX 2 // Arduino Pin connected to the TX of the Serial MP3 Player module
#define ARDUINO_TX 3 // Arduino Pin connected to the RX of the Serial MP3 Player module
SoftwareSerial mp3(ARDUINO_RX, ARDUINO_TX);
void setup() {
Serial.begin(9600);
mp3.begin(9600);
delay(500); // wait chip initialization is complete
byte selecttf[] = { 0x7E, 0xFF, 0x06, 0x09, 0x00, 0x00, 0x02, 0xEF };
delay(200); // wait for 200ms
mp3.write(selecttf, sizeof(selecttf)); //Select TF Card
delay(200);
byte volume[] = { 0x7E, 0xFF, 0x06, 0x06, 0x00, 0x00, 0x1E, 0xEF };
delay(200);
mp3.write(volume, sizeof(volume)); //Set volume to full
}
void loop() {
byte play[] = { 0x7E, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x01, 0xEF };
delay(20000);
mp3.write(play, sizeof(play)); //play first song on SD card
}
ESP32:
#include <HardwareSerial.h>
HardwareSerial mp3(1);
void setup() {
Serial.begin(9600);
mp3.begin(9600, SERIAL_8N1, 21, 19); //RX21 TX19
delay(5000); // wait chip initialization is complete
byte selecttf[] = { 0x7E, 0xFF, 0x06, 0x09, 0x00, 0x00, 0x02, 0xEF };
mp3.write(selecttf, sizeof(selecttf)); // select the TF card
delay(2000);
byte volume[] = { 0x7E, 0xFF, 0x06, 0x06, 0x00, 0x00, 0x1E, 0xEF };
mp3.write(volume, sizeof(volume)); //set volume to max
delay(2000);
}
void loop() {
byte play[] = { 0x7E, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x01, 0xEF }; //// Play first mp3 on card
mp3.write(play, sizeof(play));
delay(20000);
}
I know this must be really simple and obvious, but I’m at a loss. Any help is appreciated!
