Skip to content

Commit 3f93886

Browse files
authored
Update ESP12E_DFPlayer.ino
1 parent d40134f commit 3f93886

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

ESP12E_DFPlayer.ino

+8-21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
NodeMCU ESP12E + DFPlayer Mini MP3
3-
Author : ChungYi Fu (Kaohsiung, Taiwan) 2020-2-17 00:00
3+
Author : ChungYi Fu (Kaohsiung, Taiwan) 2022-6-7 20:00
44
https://www.facebook.com/francefu
55
6-
DFPlayer RX -> ESP12E gpio16
7-
DFPlayer TX -> ESP12E gpio17
6+
DFPlayer RX -> ESP12E TX
7+
DFPlayer TX -> ESP12E RX
88
99
Sample Code
1010
https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299
@@ -18,9 +18,9 @@ Default APIP: 192.168.4.1
1818
STAIP:
1919
Query: http://192.168.4.1/?ip
2020
Link:http://192.168.4.1/?resetwifi=ssid;password
21-
2221
If you don't need to get response from ESP8266 and want to execute commands quickly,
2322
you can append a parameter value "stop" at the end of command.
23+
2424
For example:
2525
http://192.168.4.1/?digitalwrite=gpio;value;stop
2626
http://192.168.4.1/?restart=stop
@@ -29,8 +29,8 @@ http://192.168.4.1/?restart=stop
2929
#include <ESP8266WiFi.h>
3030

3131
// Enter your WiFi ssid and password
32-
const char* ssid = ""; //your network SSID
33-
const char* password = ""; //your network password
32+
const char* ssid = "teacher"; //your network SSID
33+
const char* password = "87654321"; //your network password
3434

3535
const char* apssid = "ESP12E_DFPlayer";
3636
const char* appassword = "12345678"; //AP password require at least 8 characters.
@@ -39,8 +39,6 @@ WiFiServer server(80);
3939

4040
#include "Arduino.h"
4141
#include "DFRobotDFPlayerMini.h"
42-
#include <HardwareSerial.h>
43-
HardwareSerial mySerial(1); // RX:gpio16 TX:gpio17
4442

4543
DFRobotDFPlayerMini myDFPlayer;
4644
void printDetail(uint8_t type, int value);
@@ -50,11 +48,6 @@ byte ReceiveState=0,cmdState=1,strState=1,questionstate=0,equalstate=0,semicolon
5048

5149
void ExecuteCommand()
5250
{
53-
Serial.println("");
54-
//Serial.println("Command: "+Command);
55-
Serial.println("cmd= "+cmd+" ,P1= "+P1+" ,P2= "+P2+" ,P3= "+P3+" ,P4= "+P4+" ,P5= "+P5+" ,P6= "+P6+" ,P7= "+P7+" ,P8= "+P8+" ,P9= "+P9);
56-
Serial.println("");
57-
5851
if (cmd=="your cmd") {
5952
// You can do anything
6053
// Feedback="<font color=\"red\">Hello World</font>";
@@ -72,16 +65,12 @@ void ExecuteCommand()
7265
}
7366
else if (cmd=="resetwifi") {
7467
WiFi.begin(P1.c_str(), P2.c_str());
75-
Serial.print("Connecting to ");
76-
Serial.println(P1);
7768
long int StartTime=millis();
7869
while (WiFi.status() != WL_CONNECTED)
7970
{
8071
delay(500);
8172
if ((StartTime+5000) < millis()) break;
8273
}
83-
Serial.println("");
84-
Serial.println("STAIP: "+WiFi.localIP().toString());
8574
Feedback="STAIP: "+WiFi.localIP().toString();
8675
}
8776
else if (cmd=="volume") { // value = 0 to 30
@@ -210,9 +199,7 @@ void ExecuteCommand()
210199

211200
void setup()
212201
{
213-
mySerial.begin(9600, SERIAL_8N1, 16, 17);
214-
215-
Serial.begin(115200);
202+
Serial.begin(9600);
216203
delay(10);
217204

218205
WiFi.mode(WIFI_AP_STA);
@@ -260,7 +247,7 @@ void setup()
260247
Serial.println(F("DFRobotDemo"));
261248
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
262249

263-
if (!myDFPlayer.begin(mySerial)) { //Use softwareSerial to communicate with mp3.
250+
if (!myDFPlayer.begin(Serial)) { //Use softwareSerial to communicate with mp3.
264251
Serial.println(F("Unable to begin:"));
265252
Serial.println(F("1.Please recheck the connection!"));
266253
Serial.println(F("2.Please insert the SD card!"));

0 commit comments

Comments
 (0)