Can't Connect to DFPplayer on Arduino Every Board

Working on my first Arduino project. I am attempting to get the Arduino to play a a sound file and light a neopixel upon detecting motion. This is what I am trying to replicate...

MakerDan's Polynesian Pit Droid - YouTube

However, after working with the creator of the video for a few days....we can't figure it out. Everything seems to be connected correctly. The only difference is he has a Nano and I have a Nano Every.

In order to troubleshoot I tried a simpler sketch from this website.

Wiring DFPlayer Mini (MP3 Module) to Arduino. Stereo/Mono Diagrams. - Circuit Journal

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


// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);

// Create the Player object
DFRobotDFPlayerMini player;

void setup() {
  // Init USB serial port for debugging
  Serial.begin(9600);
  // Init serial port for DFPlayer Mini
  softwareSerial.begin(9600);

  // Start communication with DFPlayer Mini
  if (player.begin(softwareSerial)) {
    Serial.println("OK");

    // Set volume to maximum (0 to 30).
    player.volume(30);
    // Play the "0001.mp3" in the "mp3" folder on the SD card
    player.playMp3Folder(1);

  } else {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }
}

void loop() {
}

I keep getting a "Connecting to DFPlayer Mini Failed!" message. The player definitely works, as I can get it to play but jumping the IO1 pin to GRD. I have been at this for days now and just can't seem to figure it out...lol. I would really appreciate any suggestions. Thank you :slight_smile:

Do you mean Nano Every ?

If so, the Nano Every has an additional serial port (TX1/RX1 pins) and there should be no need for SoftwareSerial. Connect the player to the TX1/RX1 pins and try below sketch.

#include <DFRobotDFPlayerMini.h>

// Create the Player object
DFRobotDFPlayerMini player;

void setup() {
  // Init USB serial port for debugging
  Serial.begin(9600);
  // Init serial port for DFPlayer Mini
  Serial1.begin(9600);

  // Start communication with DFPlayer Mini
  if (player.begin(Serial1)) {
    Serial.println("OK");

    // Set volume to maximum (0 to 30).
    player.volume(30);
    // Play the "0001.mp3" in the "mp3" folder on the SD card
    player.playMp3Folder(1);

  } else {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }
}

void loop() {
}

Note: no experience with the dfplayer or the Nano Every

Yes! Sorry, it is the Nano Every....no idea what I put everday, lol. I corrected the post. Thank you for your suggestion! I will give it a try.

Why don’t you buy Nano like in the video the knock offs are dirt cheap and save Nano Every for a more serious project

That worked! Played no problem. I tried to make the same edits to the pit droid sketch...but it's doesn't seem to work. I am probably missing something. I posted the original sketch for the Nano below and the edits I made to it underneath that. All I did was remove the SoftwareSerial.h and changed SoftwareSerial to Serial1. Thanks again for your help, I spent days racking over this...lol.

// This sketch was created by Dan Massey July 4_2021.  It controls an Adafruit NeoPixel and
//a DF Player Mini to animate a Pit Droid.  It also has a switch that can control the activity level of the sounds.


#include <Wire.h> // these two lines are loading libraries to operate the NeoPixels.

#include <Adafruit_NeoPixel.h>

#define PIN 7  //this is the pin on the Arduino that goes to the input of the first NeoPixel.

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, 7, NEO_GRB + NEO_KHZ800);  //the settings for the type of NeoPixel you are using (see 8 of the lines above).

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input // these are things to remember to do if you are connecting to an actual Neopixel set.
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);


DFRobotDFPlayerMini player;// Create the DF Mini Player object

int numSongs = 31; //the number of tracks on the SD card
unsigned long lastMillis = 0; //Resets the time counter
int pirSensor = 8; // PIR Sensor is attached to pin 8
long eventInterval = 0; 

int timer = 5000;//Time delay for the eye color to stay on
int track = random(1,numSongs+1);

int highActivityInput = 5;  //variable to allow the trigger of high activity setting (connected to a switch)


void setup() {

    strip.begin(); //starts the NeoPixel sketch
    strip.show(); // Initialize all pixels to 'off'
  

    softwareSerial.begin(9600);// Initialize serial port for DFPlayer Mini
    player.begin(softwareSerial);//Begins serial communication
    player.volume(30);// Set volume to maximum (0 to 30).
    randomSeed(analogRead(A0));//Sets up a random number lottery
    pinMode(pirSensor, INPUT);//Sets the PIR sensor as an input

    pinMode (highActivityInput, INPUT);
       
}

void loop() {

  boolean highSwitch = digitalRead (highActivityInput); //checks to see if the activity swtich is set to High (active)
  
  if (highSwitch == true){ // if the high setting on the switch is turned on then then the time delay will be set to "Talk a Lot" mode:
    eventInterval = 8000; //set this to a short time interval for "Talk a Lot" mode.
  }

  if (highSwitch == false){ // if the low setting on the switch is turned on then then the time delay will be set to normal time delay mode:
    eventInterval = 60000; //set this to a longer time interval for "Normal" mode.
  }
  
int sensorValue = digitalRead(pirSensor);//reads the PIR sensor value
  if (sensorValue == 1 ) { //If the PIR sensor is triggered it will do the 2 functions below

    playtrack(); //Plays audio selection if it hasn't already been triggered within the time limit selected
   
    selectColor();//Chooses a random color for the eye
    delay (timer); // The amount of time the eye color stays on
    colorWipe(strip.Color(0, 0, 0), 300); // Resets all LEDs to off
  }

  }

// This function selects a random audio track from the SD card
void playtrack(){
    unsigned long currentMillis = millis();
        if(currentMillis - lastMillis > eventInterval){
        int track = random(1,numSongs+1); 
        player.play(track); 
    lastMillis = currentMillis;
  }
}


// This function selects a random color for the eye as well as a random intensity for the LEDs
void selectColor(){
    int Red = random (0,255);
    int Green = random (0,255);
    int Blue = random (0,255);
    colorWipe(strip.Color(Red, Green, Blue), 100);   
    
}


// This function fills the dots one after the other with a color.  
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(0);
  }
}

And here is my modification of the sketch based on your previous suggestion

// This sketch was created by Dan Massey July 4_2021.  It controls an Adafruit NeoPixel and
//a DF Player Mini to animate a Pit Droid.  It also has a switch that can control the activity level of the sounds.


#include <Wire.h> // these two lines are loading libraries to operate the NeoPixels.

#include <Adafruit_NeoPixel.h>

#define PIN 7  //this is the pin on the Arduino that goes to the input of the first NeoPixel.

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, 7, NEO_GRB + NEO_KHZ800);  //the settings for the type of NeoPixel you are using (see 8 of the lines above).

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input // these are things to remember to do if you are connecting to an actual Neopixel set.
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

#include "DFRobotDFPlayerMini.h"

DFRobotDFPlayerMini player;// Create the DF Mini Player object

int numSongs = 31; //the number of tracks on the SD card
unsigned long lastMillis = 0; //Resets the time counter
int pirSensor = 8; // PIR Sensor is attached to pin 8
long eventInterval = 0; 

int timer = 5000;//Time delay for the eye color to stay on
int track = random(1,numSongs+1);

int highActivityInput = 5;  //variable to allow the trigger of high activity setting (connected to a switch)


void setup() {

    strip.begin(); //starts the NeoPixel sketch
    strip.show(); // Initialize all pixels to 'off'
  

    Serial1.begin(9600);// Initialize serial port for DFPlayer Mini
    player.begin(Serial1);//Begins serial communication
    player.volume(30);// Set volume to maximum (0 to 30).
    randomSeed(analogRead(A0));//Sets up a random number lottery
    pinMode(pirSensor, INPUT);//Sets the PIR sensor as an input

    pinMode (highActivityInput, INPUT);
       
}

void loop() {

  boolean highSwitch = digitalRead (highActivityInput); //checks to see if the activity swtich is set to High (active)
  
  if (highSwitch == true){ // if the high setting on the switch is turned on then then the time delay will be set to "Talk a Lot" mode:
    eventInterval = 8000; //set this to a short time interval for "Talk a Lot" mode.
  }

  if (highSwitch == false){ // if the low setting on the switch is turned on then then the time delay will be set to normal time delay mode:
    eventInterval = 60000; //set this to a longer time interval for "Normal" mode.
  }
  
int sensorValue = digitalRead(pirSensor);//reads the PIR sensor value
  if (sensorValue == 1 ) { //If the PIR sensor is triggered it will do the 2 functions below

    playtrack(); //Plays audio selection if it hasn't already been triggered within the time limit selected
   
    selectColor();//Chooses a random color for the eye
    delay (timer); // The amount of time the eye color stays on
    colorWipe(strip.Color(0, 0, 0), 300); // Resets all LEDs to off
  }

  }

// This function selects a random audio track from the SD card
void playtrack(){
    unsigned long currentMillis = millis();
        if(currentMillis - lastMillis > eventInterval){
        int track = random(1,numSongs+1); 
        player.play(track); 
    lastMillis = currentMillis;
  }
}


// This function selects a random color for the eye as well as a random intensity for the LEDs
void selectColor(){
    int Red = random (0,255);
    int Green = random (0,255);
    int Blue = random (0,255);
    colorWipe(strip.Color(Red, Green, Blue), 100);   
    
}


// This function fills the dots one after the other with a color.  
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(0);
  }
}

I'm curious to know why SoftwareSerial does not work on the Nano Every. Maybe somebody has an idea?

"doesn't seem to work" is always a poor description. Can't you control the player? Do the leds not work? Something else like not compiling?

As said, not familiar with your the components of your setup. Some observations so.

  1. I do get warnings when I compile.
colorWipe(strip.Color(0, 0, 0), 300); // Resets all LEDs to off

colorWipe() takes an uint8_t as the second argument (wait); 300 does not fit in that.

But that argument is not used in the colorWipe(); so that would not be a problem

  1. The description for below is not quite correct; due to delay(0) in the function, it might look like all leds change colour at the same time.
// This function fills the dots one after the other with a color.
void colorWipe(uint32_t c, uint8_t wait) {

"doesn't seem to work" is always a poor description. Can't you control the player? Do the leds not work? Something else like not compiling?

It complies, but I get the same colorwipe warning message that you mentioned. The changes you suggested worked great with the first DFPlayer sketch I posted. I made the same changes for the Pit Droid sketch and it did not work. Meaning, no sound with motion. However, I only had the DFPlayer and motion sensor connected. I did not have the neopixel connected.

I do get warnings when I compile.

I noticed if I change the 300 to a 100, the warning goes away. I have know idea what that means as I am just a beginner with Arduinos. I copy what I see and it usually works. If it doesn't I haven't learned enough to trouble shoot the code.

colorWipe() takes an uint8_t as the second argument (wait); 300 does not fit in that.
2. The description for below is not quite correct; due to delay(0) in the function, it might look like all leds change colour at the same time.

I am sorry, I really don't know what any of that means. However, yes the LEDS all change at once.

I did receive a regular Nano in the mail last week. All I did was swap the nano every out with the nano and the original Pit Droid sketch worked perfectly. Lights came on and sound played on motion. Although I would really like to learn why it did not work on the every and how to modify the sketch so that it does. I ordered an another DFPlayer and Neopixel for me to test. You gave me a good starting point with SoftwareSerial not being needed.

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