Hello,
I'm trying to use an MP3 player on my ESP32 (Wemos D1 Mini Esp32).
Unfortunately, it doesn't work.
Here is my wiring diagram and my code. Do you see an error?
Thank you!
#include <Arduino.h>
#include "DFRobotDFPlayerMini.h"
#define RXD2 16
#define TXD2 17
HardwareSerial mySoftwareSerial(1);
DFRobotDFPlayerMini myDFPlayer;
void setup()
{
mySoftwareSerial.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.begin(115200);
myDFPlayer.begin(mySoftwareSerial);
}
void loop()
{
if(mySoftwareSerial.available() >0) {
Serial.println("Serial is available.");
Serial.println("début");
myDFPlayer.play(1);
delay(2000);
} else {
Serial.println("Serial is not available.");
}
delay(2000);
}
First and major fault is the absence of powering.
Hi Railroader,
I am not sure to understand your message.
My mp3 player is powered by the ESP32.
Maybe. I took example on this sketch:
Number one: The ESP32 has no powering.
As a consequence: Does the ESP32 have power/current capacity for that when it has no powering according to Your "wiring"? No.
nebetbastet:
I don't know if it's a language barrier issue (I'm not an English speaker), but I have the feeling that you're quite pissed off and I can't understand why.
**Pissed off is too much but the mistake is You don't show how You power the project. Powering is important and way too often considerable amounts of posting is needed to find out that the powering is way inadequate. **
I spent some time trying to get my MP3 player to work. My Serial is not recognized. I do not understand why. I'm just trying to figure out if I may have made an obvious mistake in my code or wiring.
No surprice. Just declare softwareSerial using baudrate and pins as a beginning. Use a conservative baudrate like 9600. Some 38000 is considered as an absolute maximum by several helpers.
I used Fritzing to make my diagram.
Fritzing is considered as a useless toy among many helpers. Usually the powering is left out and often a colourful bird nest that would suite a murder investigating detective.
To my knowledge, the power supply of the board is never represented on these diagrams.
Then don't use "these diagrams"!
My ESP32 is connected to my computer.
Could it be USB? USB is not a nuclear power plant. It usually supplies max 500 mA and that is often not enough. What need for current does Your circuitry have? And what is the ESP capable of supplying?
This is not a great example of how to use the additional hardware ports on the ESP32. I suspect at some point they were using Software Serial, then switched to hardware, and were too lazy to go back and tidy things up.
Get rid of this line altogether...
Replace this line...
With...
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
Change any references to
nebetbastet:
mySoftwareSerial.
to...
Serial2.
Here's a better example...
/*
* There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD.
*
* U0UXD is used to communicate with the ESP32 for programming and during reset/boot.
* U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though
* U2UXD is unused and can be used for your projects.
*
*/
#define RXD2 16
#define TXD2 17
void setup() {
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
Serial.begin(115200);
//Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.println("Serial Txd is on pin: "+String(TX));
Serial.println("Serial Rxd is on pin: "+String(RX));
}
This file has been truncated. show original
Also... why do you have this resistor in the circuit?
1 Like
It's a holdover, a TX 5V necessity.
The ESP32 is 3V so, correct, it should not be used.
1 Like
Hello again everyone,
I was able to solve the problem.
I just realized that my MP3 player had a problem: the VCC and RX pins were soldered together.
I fixed this issue and now it works.
I will nevertheless take your remarks into account and try to improve my circuit and my code according to your suggestions.
Thank you all for your answers
system
Closed
December 29, 2022, 9:53pm
12
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.