DFRobot Player Pro DF1201S Issues

I'm having issues uploading example code for this specific library. I have no issues using the DFPlayer Mini. The errors are as follows

/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp: In member function 'DFRobot_DF1201S::ePlayMode_t DFRobot_DF1201S::getPlayMode()':
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: ambiguous overload for 'operator=' (operand types are 'arduino::String' and 'char')
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:97:11: note: candidate: arduino::String& arduino::String::operator=(const arduino::String&) <near match>
  String & operator = (const String &rhs);
           ^~~~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:97:11: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: conversion from 'char' to 'const arduino::String' is ambiguous
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:74:2: note: candidate: arduino::String::String(const arduino::__FlashStringHelper*) <near match>
  String(const __FlashStringHelper *str);
  ^~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:74:2: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: invalid conversion from 'char' to 'const arduino::__FlashStringHelper*' [-fpermissive]
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:70:2: note: candidate: arduino::String::String(const char*) <near match>
  String(const char *cstr = "");
  ^~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:70:2: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:98:11: note: candidate: arduino::String& arduino::String::operator=(const char*) <near match>
  String & operator = (const char *cstr);
           ^~~~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:98:11: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:99:11: note: candidate: arduino::String& arduino::String::operator=(const arduino::__FlashStringHelper*) <near match>
  String & operator = (const __FlashStringHelper *str);
           ^~~~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:99:11: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: invalid conversion from 'char' to 'const arduino::__FlashStringHelper*' [-fpermissive]
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:100:11: note: candidate: arduino::String& arduino::String::operator=(arduino::String&&) <near match>
  String & operator = (String &&rval);
           ^~~~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:100:11: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: conversion from 'char' to 'arduino::String' is ambiguous
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:74:2: note: candidate: arduino::String::String(const arduino::__FlashStringHelper*) <near match>
  String(const __FlashStringHelper *str);
  ^~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:74:2: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: invalid conversion from 'char' to 'const arduino::__FlashStringHelper*' [-fpermissive]
    playMode = str[10];
                     ^
In file included from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/IPAddress.h:24:0,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/ArduinoAPI.h:30,
                 from /Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h:4,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.h:17,
                 from /Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:12:
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:70:2: note: candidate: arduino::String::String(const char*) <near match>
  String(const char *cstr = "");
  ^~~~~~
/Users/trentonlabiche/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.3.2/cores/arduino/api/String.h:70:2: note:   conversion of argument 1 would be ill-formed:
/Users/trentonlabiche/Documents/Arduino/libraries/DFRobot_DF1201S/src/DFRobot_DF1201S.cpp:65:21: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    playMode = str[10];
                     ^

exit status 1

Compilation error: exit status 1

Show this code. Maybe invalid play mode? you used a reserved name.

/*!
 *@file play.ino
 *@brief Music Playing Example Program
 *@details  Experimental phenomenon: control MP3 play music, obtain song information
 *@copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 *@license     The MIT license (MIT)
 *@author [fengli](li.feng@dfrobot.com)
 *@version  V1.1
 *@date  2021-10-15
 *@url https://github.com/DFRobot/DFRobot_DF1201S
*/


#include <DFRobot_DF1201S.h>
#include <SoftwareSerial.h>

SoftwareSerial DF1201SSerial(2, 3);  //RX  TX

DFRobot_DF1201S DF1201S;
void setup(void){
  Serial.begin(115200);
  DF1201SSerial.begin(115200);
  while(!DF1201S.begin(DF1201SSerial)){
    Serial.println("Init failed, please check the wire connection!");
    delay(1000);
  }
  /*Set volume to 20*/
  DF1201S.setVol(/*VOL = */20);
  Serial.print("VOL:");
  /*Get volume*/
  Serial.println(DF1201S.getVol());
  /*Enter music mode*/
  DF1201S.switchFunction(DF1201S.MUSIC);
  /*Wait for the end of the prompt tone */
  delay(2000);
  /*Set playback mode to "repeat all"*/
  DF1201S.setPlayMode(DF1201S.ALLCYCLE);
  Serial.print("PlayMode:");
  /*Get playback mode*/
  Serial.println(DF1201S.getPlayMode());

  //Set baud rate to 115200(Need to power off and restart, power-down save)
  //DF1201S.setBaudRate(115200);
  //Turn on indicator LED (Power-down save)
  //DF1201S.setLED(true);
  //Turn on the prompt tone (Power-down save) 
  //DF1201S.setPrompt(true);
  //Enable amplifier chip 
  //DF1201S.enableAMP();
  //Disable amplifier chip 
  //DF1201S.disableAMP();
}

void loop(){
  Serial.println("Start playing");
  /*Start playing*/
  DF1201S.start();
  delay(3000);
  Serial.println("Pause");
  /*Pause*/
  DF1201S.pause();
  delay(3000);
  Serial.println("Next");
  /*Play the next song*/
  DF1201S.next();
  delay(3000);
  Serial.println("Previous");
  /*Play the previous song*/
  DF1201S.last();
  delay(3000);
  Serial.println("Start playing");
  //Fast forward 10S
  DF1201S.fastForward(/*FF = */10);
  //Fast Rewind 10S
  //DF1201S.fastReverse(/*FR = */10);
  //Start the song from the 10th second 
  //DF1201S.setPlayTime(/*Play Time = */10);

  Serial.print("File number:");
  //Get file number
  Serial.println(DF1201S.getCurFileNumber());

  Serial.print("The number of files available to play:");
  //The number of files available to play
  Serial.println(DF1201S.getTotalFile());

  Serial.print("The time length the current song has played:");
  //Get the time length the current song has played 
  Serial.println(DF1201S.getCurTime());

  Serial.print("The total length of the currently-playing song: ");
  //Get the total length of the currently-playing song 
  Serial.println(DF1201S.getTotalTime());
  Serial.print("The name of the currently-playing file: ");
  //Get the name of the playing file 
  Serial.println(DF1201S.getFileName());
  delay(3000);
  //Play the file No.1, the numbers are arranged according to the sequence of the files copied into the U-disk 
  DF1201S.playFileNum(/*File Number = */1);
  //Play the test.mp3 file in test folder 
  //DF1201S.playSpecFile("/test/test.mp3");

  while(1);
  /*Delete the currently-playing file */
  //DF1201S.delCurFile();
}

I used the example code just to try and get it up and running. It wouldn't compile. I'm using a nano every with the device.

Are you using the MegaCoreX core?

Edit: if you are, open up the DFRobot_DF1201S.cpp file in the library, find the getPlayMode() function and make the change shown below:

DFRobot_DF1201S::ePlayMode_t DFRobot_DF1201S::getPlayMode()
{

   String playMode = "";
   sPacket_t cmd;
   cmd = pack("PLAYMODE", "?");
   writeATCommand(cmd.str, cmd.length);
   String str = readAck(13);
   playMode = String(str[10]);    // <<<=== CHANGE THIS LINE AS SHOWN
   //Serial.println(str);
   if (str[11] == '\r' && str[12] == '\n')
      return (ePlayMode_t)atoi(playMode.c_str());
   else
      return ERROR;

}

If you read the String reference carefully, assigning a char to a String isn't actually mentioned. It shows passing a char to the String constructor, but not assigning a char to a String. A simple test shows how it fails, even with a plain vanilla Uno R3:

void setup() {
   char c = 'a';
   Serial.begin(115200);
   String s = c;
   Serial.println(s);
}

void loop() {
}
arduino-cli compile -b arduino:avr:uno --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Uno_R3/test)
/home/me/Documents/sketchbook/Uno_R3/test/test.ino: In function 'void setup()':
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:4:15: error: conversion from 'char' to 'String' is ambiguous
    String s = c;
               ^
In file included from /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/Arduino.h:232:0,
                 from /home/me/.cache/arduino/sketches/1644C018203C728920BB2C3A95076DE5/sketch/test.ino.cpp:1:
/home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/WString.h:61:2: note: candidate: String::String(const __FlashStringHelper*) <near match>
  String(const __FlashStringHelper *str);
  ^~~~~~
/home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/WString.h:61:2: note:   conversion of argument 1 would be ill-formed:
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:4:15: warning: invalid conversion from 'char' to 'const __FlashStringHelper*' [-fpermissive]
    String s = c;
               ^
In file included from /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/Arduino.h:232:0,
                 from /home/me/.cache/arduino/sketches/1644C018203C728920BB2C3A95076DE5/sketch/test.ino.cpp:1:
/home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/WString.h:59:2: note: candidate: String::String(const char*) <near match>
  String(const char *cstr = "");
  ^~~~~~
/home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/WString.h:59:2: note:   conversion of argument 1 would be ill-formed:
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:4:15: warning: invalid conversion from 'char' to 'const char*' [-fpermissive]
    String s = c;
               ^
Used platform Version Path
arduino:avr   1.8.3   /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3
Error during build: exit status 1
Compilation failed.

and how using the String constructor gets around it:

void setup() {
   char c = 'a';
   Serial.begin(115200);
   String s = String(c);
   Serial.println(s);
}

void loop() {
}
arduino-cli compile -b arduino:avr:uno --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Uno_R3/test)
Sketch uses 2670 bytes (8%) of program storage space. Maximum is 32256 bytes.
Global variables use 198 bytes (9%) of dynamic memory, leaving 1850 bytes for local variables. Maximum is 2048 bytes.
Used platform Version Path
arduino:avr   1.8.3   /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3
Compilation finished successfully.

Yes, I believe so, Im not currently at home but its the hardware packaged used with the arduino nano every. I will make the changes as soon as i get the chance. Sorry, I'm fairly new to arduino and still learning, but i do appreciate the assistance.

This one's most definitely not on you; even a brief look at that library elicited a few "really?" and raised eyebrows. I don't know who wrote it but it could have used a good code review before it was released. Good luck with it!

Well, thank you thank you. That helped me get it up and running. The crazy thing is I saw someone use this library on youtube and they had it working fine. They didnt mention anything about having to make these changes.

The example and library compiled error free on an Uno R3 for me as well. It wasn't until I went to that stripped down sketch that it complained. Given that the only differences I saw in the String implementations on both platforms were formatting, the library ought to have failed there as well. Shrug! Sometimes, you just take the win and hope that it doesn't come back later to bite you.

I had also tried on an Uno R4 wifi and it didnt like the library either lol. Guess I should have tried an older R3. Thanks again. That really brightened my day!!! Hope you and yours have a Happy New Year!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.