Build it step by step
0 of 7 doneWire the DFPlayer
TX to D10, RX to D11 through 1 kΩ, speaker on its SPK pins.
Load the songs
FAT32 card with files 0001.mp3, 0002.mp3 and so on.
Add the clock
RTC on A4 and A5. The first upload sets the time, so upload just after compiling.
Add the button
Doorbell push button between D2 and ground, on long wires to the front door.
Upload and test
Press the button and a random track plays.
Check quiet hours
Temporarily set the RTC or the quiet times to test the lower volume.
Fit it
Put it in a box by the door and power it from a USB adapter.
How do you build a custom tune doorbell?
Press the doorbell and a DFPlayer plays a random song from a microSD card, with quiet hours at night. You need Arduino Nano, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, Tactile push button 6 mm, DS3231 RTC module, SanDisk microSD card 32 GB (A1, Class 10), Resistor 1 kΩ, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and 5 V 2 A USB adapter. It takes 7 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 10
Wiring
| From | To | Why |
|---|---|---|
| DFPlayer VCC and GND | Nano 5V and GND | Supply |
| DFPlayer TX | Nano D10 | Data to the Nano |
| DFPlayer RX | Nano D11 through 1 kΩ | Data from the Nano |
| DFPlayer SPK_1 and SPK_2 | Speaker | Sound |
| RTC SDA and SCL | Nano A4 and A5 | Clock |
| Doorbell button | Nano D2 and GND | Press to ring |
| Power | 5 V USB adapter | Runs from a wall socket through the adapter only |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "DFRobotDFPlayerMini" and "RTClib". Use songs you own or have the right to use, saved as 0001.mp3 and up on a FAT32 microSD card. The button is a low-voltage push button wired to the Nano and the whole circuit runs from a USB adapter, so there is no mains wiring.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
#include <Wire.h>
#include <RTClib.h>
SoftwareSerial ss(10, 11);
DFRobotDFPlayerMini dfp;
RTC_DS3231 rtc;
const byte BTN = 2;
const byte TRACKS = 8; // number of files on the card, 0001.mp3 up
unsigned long lockUntil = 0;
void setup() {
pinMode(BTN, INPUT_PULLUP);
ss.begin(9600);
dfp.begin(ss);
rtc.begin();
if (rtc.lostPower()) rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
randomSeed(analogRead(A0));
}
void loop() {
if (digitalRead(BTN) == LOW && millis() > lockUntil) {
int h = rtc.now().hour();
bool quiet = (h >= 21 || h < 6); // quiet hours from 9 pm to 6 am
dfp.volume(quiet ? 8 : 24);
dfp.play(random(1, TRACKS + 1));
lockUntil = millis() + 5000; // ignore presses for 5 seconds
}
delay(20);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Press the button | A random track plays |
| Press again within 5 s | Ignored |
| During the day | Loud volume |
| After 9 pm | Quiet volume |
If it does not work
No sound
SD card not FAT32 or the files are not named as 0001.mp3.
Hiss or crackle
Use a good 5 V supply and keep the speaker leads short.
Wrong volume at night
RTC time is wrong. Reset it.
Always plays the same track
randomSeed uses an unconnected pin, which is fine. Check TRACKS matches the files.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the custom tune doorbell?
Arduino Nano, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, Tactile push button 6 mm, DS3231 RTC module, SanDisk microSD card 32 GB (A1, Class 10), Resistor 1 kΩ, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and 5 V 2 A USB adapter.
How long does the custom tune doorbell take to build?
About 60 minutes for a beginner maker, in 7 steps.
How do I know the custom tune doorbell works?
Press the button: A random track plays. Press again within 5 s: Ignored. During the day: Loud volume.
No sound: what should I check?
SD card not FAT32 or the files are not named as 0001.mp3.
Hiss or crackle: what should I check?
Use a good 5 V supply and keep the speaker leads short.
Wrong volume at night: what should I check?
RTC time is wrong. Reset it.
Always plays the same track: what should I check?
randomSeed uses an unconnected pin, which is fine. Check TRACKS matches the files.
