Hi, I'm newbie. Can connect esp32cam with df player mini? I have try it with arduino, it's working, but not with esp32cam
Here is my code:
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(16,14); //RX, TX
// Create the Player object
DFRobotDFPlayerMini myDFPlayer;
void setup() {
mySoftwareSerial.begin(9600);
Serial.begin(115200);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true);
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.setTimeOut(500); //Set serial communictaion time out 500ms
//----Set volume----
myDFPlayer.volume(25); //Set volume value (0~30).
//----Set different EQ----
myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
//----Set device we use SD as default----
myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
myDFPlayer.play(2);
delay(62000);
//----Read imformation----
Serial.println("state" + myDFPlayer.readState()); //read mp3 state
Serial.println("all file" + myDFPlayer.readFileCounts()); //read all file counts in SD card
Serial.println("current" + myDFPlayer.readCurrentFileNumber()); //read current play file number
Serial.println("read fill"+ myDFPlayer.readFileCountsInFolder(3)); //read fill counts in folder SD:/03
}
void loop() { }
The message error is: Unable to begin
Is it have problem with mySoftwareSerial?
Please help me, thanks a lot
Software Serial should only ever be used when there are no hardware serial (UART) ports available. This is why it is frequently used in code intended to run on Uno. Uno has only one hardware serial port, and that's not available because it's used for uploading code and serial monitor.
But ESP32 have at least 2 available hardware serial ports, and I understand they are configurable to use any available pins. So this is what you should be aiming to achieve with ESP32CAM, as far as I know.
Could you explain more, I'm just newbie
I have code like this, is it correct as your idea?
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include "SD_MMC.h"
DFRobotDFPlayerMini myDFPlayer;
void setup() {
Serial.begin(115200);
Serial2.begin(9600,SERIAL_8N1,13,12);
// ---- Set device we use SD as default ----
if (!SD_MMC.begin("/sd", true)) {
Serial.println(F("Card Mount Failed"));
// return;
}
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
if (!myDFPlayer.begin(Serial2)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true);
}