ESP8266上的音频播放模块无法初始化

时间:2018-02-06 19:26:29

标签: arduino esp8266

我有ESP8266(ESP-12-E)和DFPlayer Mini

我正在运行示例应用程序:

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

SoftwareSerial mySoftwareSerial(2, 5); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

void setup()
{
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);

  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //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);
  }
  Serial.println(F("DFPlayer Mini online."));

  myDFPlayer.volume(10);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3
}

void loop()
{
  static unsigned long timer = millis();

  if (millis() - timer > 3000) {
    timer = millis();
    myDFPlayer.next();  //Play next mp3 every 3 second.
  }

  if (myDFPlayer.available()) {
    printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }
}

void printDetail(uint8_t type, int value){
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
}

我在DFP8M1上设置了以下引脚设置,从主板1-8的左侧开始倒计时:

1 - +5v
2 - ESP-12-E GPIO 2 - Software serial TX
3 - ESP-12-E GPIO 5 - Software serial RX
4 - 
5 - 
6 - Speaker +
7 - GND
8 - Speaker - 

串行监视器显示:

  

DFRobot DFPlayer Mini演示初始化DFPlayer ...(可能需要3~5个   秒)无法开始:   1.请重新检查连接!   2.请插入SD卡!

     

软WDT重置

     

ctx:cont sp:3ffefc30 end:3ffefe10 offset:01b0

     
    
      
        

堆>>> 3ffefde0:3ffeeab0 3ffeea88 3ffeed2c 402020c4 3ffefdf0:3fffdad0 00000000 3ffeeddc 40202fc4 3ffefe00:feefeffe feefeffe         3ffeedf0 40100710<<       

    
  
     

ets 2013年1月8日,第一个原因:2,启动模式:(3,6)

格式化的堆栈跟踪是:

Decoding 3 results
0x402020c4: setup at /Users/user/Documents/Arduino/dfplayer_simple/dfplayer_simple.ino line 42
0x40202fc4: loop_wrapper at /Users/user/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/core_esp8266_main.cpp line 57
0x40100710: cont_norm at /Users/user/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0/cores/esp8266/cont.S line 109

我发现DFPlayer Mini LED上没有任何活动,我不确定从何处开始。

2 个答案:

答案 0 :(得分:0)

有点晚了,但是如上所述,使用myDFPlayer.begin(mySoftwareSerial,false)是我们尝试过的每个'duino(esp8266,esp32,mega,uno,teensy等)的工作。最好完全删除该校验码,因为一旦您告诉它没有应答,即使没有连接DFPlayer,它也将通过测试。

答案 1 :(得分:0)

在我的NodeMCU ESP-12E上,由于标签vs. GPIO别名,而不是

SoftwareSerial mySoftwareSerial(5,6); //didn't work

我不得不使用

SoftwareSerial mySoftwareSerial(D5,D6); //worked great!

使用Arduino IDE,NodeMCU 1.0 ESP-12E开发板。很奇怪我在网上遇到的样本没有显示此细节。这是指向各种esp8266开发板的引脚参考和其他信息的链接。 https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/