Objective: To continuously play a 5-second MP3 file with a 10-second gap between each play.
Issue Description: When connecting the NodeMCU to an external power source, the sound does not play until the reset button is pressed.
Observations:
- Sound plays upon initial upload but fails to play on subsequent power connections.
- Sound resumes after pressing the reset button.
- Sound plays when NodeMCU is powered first, and then the DFPlayer power connection is made.
- An exception message is displayed in the Arduino serial monitor when NodeMCU is connected from the laptop. Which is subsequently called the "Soft WDT reset" and then the code starts running.
Connection Diagram:
Code:
#include <Arduino.h>
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
#define RX_PIN D6 // Connect D5 of NodeMCU to RX of DFPlayer Mini
#define TX_PIN D5 // Connect D6 of NodeMCU to TX of DFPlayer Mini
SoftwareSerial mySoftwareSerial(RX_PIN, TX_PIN); // Create a software serial port
DFRobotDFPlayerMini myDFPlayer; // Create an instance of the DFPlayer Mini
void setup() {
mySoftwareSerial.begin(9600);
Serial.begin(9600);
if (!myDFPlayer.begin(mySoftwareSerial)) { // Use software serial to communicate with DFPlayer Mini
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."));
myDFPlayer.setTimeOut(500); // Set serial communication timeout to 500ms
// Increase the volume to maximum
myDFPlayer.volume(30); // Set volume value (0~30)
}
void loop() {
myDFPlayer.play(1);
delay(5000);
}
Serial Monitor log :(next time connect with the laptop)
Unable to begin:
1.Please recheck the connection!
2.Please insert the SD card!
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Soft WDT reset
Exception (4):
epc1=0x4000dcfe epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffe00 end: 3fffffd0 offset: 0160
3fffff60: 3ffee4ec 00000000 0000130a 40202b0d
3fffff70: 00000000 004a60fa 3ffee4ec 3ffee63c
3fffff80: 402022b8 3ffe87bc 3ffee5bc 3ffee63c
3fffff90: 3ffee4ec 3ffee5bc 00000000 40203122
3fffffa0: 0000000e 3ffee5bc 3ffee514 40201170
3fffffb0: 3fffdad0 00000000 3ffee610 40202bb4
3fffffc0: feefeffe feefeffe 3fffdab0 4010139d
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
DFPlayer Mini online.
Any assistance or guidance to resolve the issue and ensure continuous playback without manual intervention would be greatly appreciated.
Best regards
2 posts - 2 participants