Go Down

Topic: DfPlayerMiniMp3, Esp8266, and SoftwareSerial not working together (Read 97 times) previous topic - next topic

perigalacticon

Has anyone got a DfPlayerMini Mp3 player to work on an Esp8266 with SoftwareSerial?
Could you let me know what settings to use?

In the sketch I have:
Code: [Select]
#include <DFPlayer_Mini_Mp3.h>
#include <SoftwareSerial.h>

#define DFPLAYER_RX_PIN     0  // for debug so serial monitor will work.
#define DFPLAYER_TX_PIN     2  // for debug so serial monitor will work.

SoftwareSerial dfplayerSerial(DFPLAYER_RX_PIN, DFPLAYER_TX_PIN);  //  RX, TX.  connect to reciprocal module pins.


Code: [Select]
void setup(){
 dfplayerSerial.begin(9600, SWSERIAL_8N1, DFPLAYER_RX_PIN, DFPLAYER_TX_PIN, false, 256);
 mp3_set_serial (dfplayerSerial);}



When I run the sketch it has an error that it can't set the player serial, because it thinks the software serial is a hardware serial:

Code: [Select]
Halloween_Box_Head_Skeleton1.ino: In function void setup()
 
Halloween_Box_Head_Skeleton1.ino: 99:33: error: invalid initialization of reference of type 'HardwareSerial&' from expression of type 'SoftwareSerial
   mp3_set_serial (dfplayerSerial)
 
Halloween_Box_Head_Skeleton1.ino:17: In file included from
 
DFPlayer_Mini_Mp3.h: 78:6: error: in passing argument 1 of 'void mp3_set_serial(HardwareSerial&)
   void mp3_set_serial (HardwareSerial &theSerial)
Error compiling project sources
Build failed for project 'Halloween_Box_Head_Skeleton1'



I downloaded the espsoftwareserial library but I don't understand if it's being used or not, it seems very confusing as to what to do with this library so that it is used correctly in my sketch with Esp8266, what do you have to do?

 
In the DFPlayer_Mini_Mp3 source files there are 2 definitions for the "mp3_set_serial" function:

Code: [Select]
void mp3_set_serial (HardwareSerial &theSerial);

//
void mp3_set_serial (SoftwareSerial &theSerial);


If I comment out all references to the hardware serial option in the .h and .cpp files I get this error instead:

Code: [Select]
Halloween_Box_Head_Skeleton1.ino: In function void setup()
 
Halloween_Box_Head_Skeleton1.ino: 99:33: error: 'mp3_set_serial' was not declared in this scope
   mp3_set_serial (dfplayerSerial)


So I think my SoftwareSerial is not working right with Esp8266, because I have compiled a similar sketch with a Pro Mini Uno and it runs fine.

Thanks!

Interactive addressable led displays for holidays; interactive robots for fun.

Power_Broker

The library you're using rn is depricated. Try using a better library (installable through the Arduino IDE's Libraries Manager) and see if that fixes things
"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

perigalacticon

Thanks I used that library and it works perfectly the first time.

Interactive addressable led displays for holidays; interactive robots for fun.

Go Up