I am brand new at using Arduinos but know how to program. I am attempting to use a DFPlayer Mini (DFP) MP3 player with my Nano Sense. I believe that I've tracked the issue down to the fact that I've got no idea if my attempts to use serial communications between the Nano and DFP are working. (I have connected a different board and failed to communicate with it as well which is why I'm pretty certain it's a serial communication issue).
The Nano is connected to my Windows 10 machine by the USB cable. I am able to use Serial Monitor to get information from the Nano indicating that it's not talking to anything. This connection is live while I'm attempting the one between the Nano and DFP.
I'm using IDE 1.8.13.
The sample DFP code uses softwareSerial, which I understand is not applicable to the Sense. I have attempted to use the following to define mySerial to no avail.
UART mySerial(digitalPinToPinName(11), digitalPinToPinName(10), NC, NC); // create a hardware serial port named mySerial with RX: pin 10 and TX: pin 11
(If somebody can direct me to documentation about this code I would really appreciate it. I totally struck out using both Google and Duck Duck.)
I have also attempted to use Serial1 to no avail, as in the code below. (note that some comments are leftover from the factory example sketch and therefore incorrect.)
/***************************************************
DFPlayer - A Mini MP3 Player For Arduino
<https://www.dfrobot.com/product-1121.html>
***************************************************
This example shows the basic function of library for DFPlayer.
Created 2016-12-07
By [Angelo qiao](Angelo.qiao@dfrobot.com)
GNU Lesser General Public License.
See <http://www.gnu.org/licenses/> for details.
All above must be included in any redistribution
****************************************************/
/***********Notice and Trouble shooting***************
1.Connection and Diagram can be found here
<https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299#Connection_Diagram>
2.This code is tested on Arduino Uno, Leonardo, Mega boards.
****************************************************/
#include <Arduino.h>
#include "DFRobotDFPlayerMini.h"
//#include "wiring_private.h"
//UART mySerial(digitalPinToPinName(11), digitalPinToPinName(10), NC, NC); // create a hardware serial port named mySerial with RX: pin 10 and TX: pin 11
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
void setup()
{
Serial1.begin(9600);
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
if (!myDFPlayer.begin(Serial1)) { //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) {
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));
<snip>
When I attempt to run the sketch the Monitor shows the output in the (!myDFPlayer.begin(Serial1)) if loop, indicating no communication. I snipped the remainder of the code out as it never executes.
Bonus question: Is there a way I can test to ensure that the Nano is attempting to send serial communications? (I know how to verify that code to send signals is processing. I need to verify that the signals are actually being sent.)
Thank you all in advance. I've been chasing my tail for days.