Author Topic: DFPlayer mini tutoria with "error" but works  (Read 212 times)

0 Members and 1 Guest are viewing this topic.

Offline Youkai

  • Regular Contributor
  • *
  • Posts: 149
  • Country: us
DFPlayer mini tutoria with "error" but works
« on: May 16, 2020, 06:41:47 am »
I can't figure out why this tutorial for the DFPlayer mini works. It seems to me that there is a clear error in the programming code. The tutorial: https://circuitjournal.com/how-to-use-the-dfplayer-mini-mp3-module-with-an-arduino

If you look at the code there is this section:
Code: [Select]
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);
You can clearly see that the item he has commented as "RX" is the "TX" variable. But the TX variable is using the pin that is going to RX in the diagrams.

The RX and TX are swapped in the code but it actually works that way. I tried "fixing" the code and you get no audio. As far as I can tell from the wiring diagram and the documentation on "SoftwareSerial" this code should be incorrect. What am I missing?
 

Offline OwO

  • Super Contributor
  • ***
  • Posts: 1232
  • Country: cn
  • RF Engineer @ OwOComm. Discord: スメグマ#2236
Re: DFPlayer mini tutoria with "error" but works
« Reply #1 on: May 16, 2020, 02:36:34 pm »
Maybe think about it a bit more  ;) ;)
Discord: スメグマ#2236
Email: OwOwOwOwO123@outlook.com
GitHub: gabriel-tenma-white
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 2967
  • Country: ca
Re: DFPlayer mini tutoria with "error" but works
« Reply #2 on: May 16, 2020, 04:05:12 pm »
They are not swaped in the code,  you define the tx and rx pins of the arduino board going to the module

you use pin 2 as the tx of the arduino board
you use pin 3 as the rx of the arduino board

The wire connections "are" crossed  going to the mp3 module


another page
https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299#target_7
 
The following users thanked this post: Youkai

Offline Youkai

  • Regular Contributor
  • *
  • Posts: 149
  • Country: us
Re: DFPlayer mini tutoria with "error" but works
« Reply #3 on: May 17, 2020, 04:15:30 am »
Thanks. I looked at the comments from the source code a little more carefully and figured it out. Good to see confirmation though :)

I didn't get that at first which is probably why my original sketch with a different library didn't work lol.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf