Blocking Arduino + Bluetooth + DfPlayer

Hello,

I built a speaking robot system with Arduino UNO + Bluetooth + DfPlayer. I am sending a string from my Android phone and the system reads me an Mp3 file stored in SD card.

At the beginning this was working perfectly but it started to be blocked. i.e. after sending 2 strings, it does not respond.

If there was an erroneous wiring or software, it wouldn't work either in the first 2 attempts.

Any comments ?

Do you think that it might help if you posted your sketch, using code tags when you do, and a schematic of your project ?

UKHeliBob, thanks for your message. Yes, sending the sketch and a schematic might help to solve the problem.

Here is the schematic :

Notes :

  1. I am making my circuit on a PCB. This schematic shows the back side of the PCB.
  2. On this schematic, the KA-2284 (which is a VU-meter) is used to make lip-synch (just imitate randomly the lip movements). I am making my tests without KA-2284. I have not yet added the related code into the sketch.
  3. I put all devices and PCB in a plastic mannequin head. I placed the DfPlayer not on the PCB but at a remote place to facilitate the access to the SD card to add or edit Mp3 files. For this reason, I used extension cables as shown on the schematic.
  4. The mannequin head will move its eyelids up and down; its eyeballs right and left and up and down; its jaws up and down.

Here is the sketch :

//------Bluetooth test with DfPlayer----

#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>

SoftwareSerial Bluetooth(4, 5);
SoftwareSerial SesCalarModulu(6, 7);

DFRobotDFPlayerMini Ses_calar;
//==============================================================
void setup()
{
  Bluetooth.begin(9600);
  delay(2000);

  Serial.begin(9600);
  delay(2000);

  SesCalarModulu.begin(9600);
  delay(2000);

  while (!Serial) { ; }
  Serial.println("Bluetooth test with DfPlayer");
  //--------------------------------------------------------------
    if (!Ses_calar.begin(SesCalarModulu)) 
    {
      Serial.println(F("Başlatılamıyor:"));
      Serial.println(F("1.Lütfen bağlantınızı kontrol ediniz!"));
      Serial.println(F("2.SD kartı takınız!"));

      while(true)
       {
         delay(0);
       }
    }
      Ses_calar.playMp3Folder(62);
      Serial.println("Ses çalar bağlandı");
      delay(1000); 
}
//==============================================================
void loop() 
{
  Bluetooth.listen();
  if (Bluetooth.available() > 0) 
    {
      String Gelen_mesaj=Bluetooth.readString();       
      String Gelen_bilgi = Gelen_mesaj.substring(4,Gelen_mesaj.length()); 

      Serial.println(Gelen_bilgi);

      if (Gelen_bilgi=="Sence zaman akıyor mu")
        {
          Ses_calar.playMp3Folder(64);
          Gelen_bilgi="";
          delay(2000);
        }  
      else if (Gelen_bilgi=="Merhaba")
        {
          Ses_calar.playMp3Folder(32);
          Gelen_bilgi="";
          delay(2000);
        }
      else if (Gelen_bilgi=="Sence zaman ve mekan nedir")
        {
          Ses_calar.playMp3Folder(65);
          Gelen_bilgi="";
          delay(2000);
        }
    } 
}      

I can certainly imagine those messages getting out of sync. readString is probably not the beat tool here. Maybe readStringUntil would be better. Or even better would be to use the method in the Serial Input Basics thread in the tutorials section.

DFPlayer sends feedback to signal when it is done or has a problem.

Your code seems to assume never having any problem.

Hello,

I found the solution in an unexpected manner :

In my sketch I had used DFRobotDFPlayerMini.h, now I suddenly had the idea to change it, assuming that probably it became obsolete or incompatible with new generation DfPlayer or Bluetooth or UNO. I downloaded DFPlayerMini_Fast.h library that I found by coincidence on Internet and it solved the problem.

Thanks a lot for your contributions.