Wednesday, September 3, 2025
Tuesday, September 2, 2025
How to Build an Automatic Station Identification using Arduino and DF Player
One of my recent weekend project is the automatic station identifier using Arduino Nano, DFPlayer and DS1307 RTC module. These three modules were integrated on a compact 2 x 3 inch printed circuit board with the addition of a general-purpose transistor to reliably key the transmitter at pre-programmed intervals.
The code for this project was initially generated with the assistance of ChatGPT. Subsequent refinements included the incorporation of additional libraries and code modifications to ensure proper functionality.
Below is the code.
.......................................................................................................................................................................
#include <Wire.h>
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include "uRTCLib.h"
uRTCLib rtc(0x68);
SoftwareSerial mySerial(10, 11); // D10 = TX, D11 = RX
DFRobotDFPlayerMini myDFPlayer;
const int busyPin = 7; // DFPlayer BUSY pin
const int playLed = 5; // Indicator output (HIGH while playing)
int lastMinute = -1;
void setup() {
delay (1000); //This is included to allow the reset of arduino.
pinMode(busyPin, INPUT);
pinMode(playLed, OUTPUT);
digitalWrite(playLed, LOW);
Serial.begin(9600);
mySerial.begin(9600);
#ifdef ARDUINO_ARCH_ESP8266
URTCLIB_WIRE.begin(0, 2); // D3 and D4 on ESP8266
#else
URTCLIB_WIRE.begin();
#endif
//rtc.set(45, 29, 19, 6, 23, 8, 25);
// RTCLib::set(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)
if (!myDFPlayer.begin(mySerial)) {
Serial.println("Unable to begin DFPlayer Mini");
while (1);
}
myDFPlayer.volume(23); // set volume (0–30)
}
void loop() {
rtc.refresh();
// --- Show realtime clock every second ---
Serial.print(rtc.year());
Serial.print('/');
Serial.print(rtc.month());
Serial.print('/');
Serial.print(rtc.day());
Serial.print(" ");
Serial.print(rtc.hour());
Serial.print(':');
Serial.print(rtc.minute());
Serial.print(':');
Serial.println(rtc.second());
// --- Every 30 minutes playback trigger ---
if (rtc.minute() % 15 == 0 && rtc.minute() != lastMinute && rtc.second() == 0) {
lastMinute = rtc.minute();
Serial.println("Playing MP3...");
myDFPlayer.play(1); // Play first MP3 file (0001.mp3 on SD card)
}
// --- Monitor DFPlayer BUSY line ---
if (digitalRead(busyPin) == LOW) {
digitalWrite(playLed, HIGH); // Playing
} else {
digitalWrite(playLed, LOW); // Idle
}
delay(1000);
}
.......................................................................................................................................................................
The program is configured to trigger the DFPlayer module at 15 minute interval throughout the hour. During idle periods, the system continuously outputs real-time clock data via the Arduino serial interface. This feature provides an external monitoring capability and allows RTC calibration when necessary.
When the scheduled event occurs, the Arduino simultaneously initiates audio playback on the DFPlayer and signal digital pin 5 to key the transmitter PTT. The Arduino also monitors the busy pin of the DFPlayer via digital pin 7, enabling the microcontroller to accurately determine the end of the audio playback. This ensures that the transmitter's PTT is released in precise synchronization with the termination of the station identification message.
The video below demonstrates the project in operation, keying an Icom IC-2200H radio transceiver. In the future, I am planning to modify the code to include automated time announcement in addition to the station identification feature. ---73 de du1vss