Make a donation
Free and royalty-free sounds library for yours commercial or personal projects.
EN - FR
Logo of the website BigSoundBank.com
Logo of the website BigSoundBank.com
⚠️ BigSoundBank needs you to stay alive! Make a (small) donation ⚠️
All folders

Building a Sound Box (with an Arduino and a DFPlayer)

There is a french version of this document.

In a previous guide, we saw how to use the "DFPlayer" audio player to build a sound box very easily. Today, I suggest connecting it to an "Arduino" microcontroller (or a clone, like I use) to make it more versatile and "intelligent". In another guide, I also explained how to build a sound box with a Raspberry Pi (multi-track possible). As always, if you have any questions: contact me!

If you're not a DIYer, I offer the entire set, already built and soldered, in my shop: the "Ambi'son" module.

Here’s an illustration of what can be done with a DFPlayer + Arduino. My famous "Quiz'O'Phone, Christmas special":

https://www.youtube.com/embed/RkAtNBXJRT0

But also:

YOUR ATTENTION PLEASE!

DF Player Mini modules come in various versions, from different manufacturers and suppliers. I don't know which DFPlayer you have, or will get, and what it will be capable of.

More information in my guide on the "DF Player Mini".

Overview

The DFPlayer is a small component that plays audio files stored on its micro-SD card. It has a stereo "Line" output and even a 3W (mono) amplified output. It's very easy to use, but on its own, it's quite basic. The Arduino will be in charge of giving it orders.

The Arduino is a "microcontroller," which means it's a small computer. It doesn't have an OS (unlike Raspberry Pi), but it can run a small program written in C++. It will control our DFPlayer to make it autonomous.

In the long run, since the Arduino has many inputs and outputs, you could create whatever you want based on this guide:

Here is a short video illustration before detailing step by step how to set up the same installation:

https://www.youtube.com/embed/YcwIW-BHD_4

Step by step

1. Preparation

Take an Arduino. The "Nano" version is powerful enough for our low-demand usage. No need to buy a brand-name "Arduino" for €20. A Chinese clone for €3 works just as well. In any case, both are made in China...

You'll also need a DFPlayer, a breadboard, some wires, a 1 kOhm resistor (1,000 Ohms), as well as a jack socket and headphones, or a 3W / 4 Ohms speaker. You'll need a computer to power the Arduino and program it.

You also need to insert a micro SD card into the DFPlayer containing several MP3, WAV, or WMA files. Preferably short files, downloaded from LaSonotheque.org, to quickly see the result of this tutorial.

2. Wiring

We will place the jack (or speaker), the Arduino, and the DFPlayer on the breadboard so that all the pins are independent. Then follow this wiring diagram.

dossiers/dossier-62/raspberry-dfplayer2.webp

In this diagram, the DFPlayer is powered by the 5V and GND from the Arduino. We connect the TX, RX, and Busy pins of the DFPlayer to the D13, D12, and D11 pins of the Arduino, and connect a jack socket or a 3W / 4 Ohms speaker to the output of the DFPlayer. Don't forget the 1 kOhm resistor.

In general, it should look like this, with USB power and a 3W speaker:

dossiers/dossier-62/prototypage.webp

It's not mandatory to connect the Busy pin from the DFPlayer; many tutorials don't mention it. However, I personally find it essential for many uses, so I recommend using it too.

The power for the whole setup will be provided by the USB cable that connects the computer to the Arduino for programming. Later, you can supply 5V to the "5V" pin or between 7 and 12V to the "Vin" pin of the Arduino.

3. Programming

The idea is to write a C++ program on the computer and then upload it to the Arduino.

Download and install the "Arduino IDE" application on your computer (for Mac, Linux, and Windows). An IDE (Integrated Development Environment) gathers all the necessary tools for programming the Arduino.

Once in the IDE, go to "Manage Libraries" and install "DFRobotDFPlayerMini.h". Version 1.0.3 works best for me.

Next, I suggest copying/pasting the entire code. Or right-click on this link to directly download the file:

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

SoftwareSerial mySoftwareSerial(12,13);
DFRobotDFPlayerMini myDFPlayer;

void setup() {
  delay(3000);
  
  mySoftwareSerial.begin(9600);
  Serial.begin(9600);
  
  pinMode(11,INPUT_PULLUP);
  
  if (!myDFPlayer.begin(mySoftwareSerial)) {
    Serial.println(F("Communication error: check SDcard"));
    while(true);
  }
  
  myDFPlayer.setTimeOut(500);
  
  myDFPlayer.volume(30);
  myDFPlayer.play(1);
}

void loop() {
  if(digitalRead(11)==1) {
    play();
  }
}

void play() {
  myDFPlayer.next();

  delay(500);
}

Once the program is pasted, click on the arrow pointing to the right at the top to "Upload". A few seconds later, the program will be on the Arduino.

The Arduino will play the next file every time the previous one finishes.

To explain this code simply:

4. Going further (optional)

It is possible to use many other functions:

Known Issues

No technical project is without issues. Indeed, I have encountered many:

So, with these few points, I hope to help you solve the main ones I have encountered:

Conclusion

Building such a project is not difficult. Just follow my instructions precisely. However, if you have any issues, as always: contact me!

- Joseph SARDIN - Founder of BigSoundBank.com - About - Contact

Rate, Comment!


Comments

Be the first to give an opinion!

Cut out following the dots