Overview:
In this project we are going to see how to construct an alarm clock using Arduino which plays your favorite MP3 track as alarm tone. The proposed project sport a 16 x 2 LCD which displays time, date and various settings which can be accessed using five push buttons provided and you can set up to 5 alarms.
The objective of this awesome alarm clock is to wake you in the morning (or at any time) peacefully with a sweet music of your choice instead of angry voice of your hubby or the beeping tone from alarm clock which might annoy you at every morning.
Circuit Diagram:
The above circuit can be constructed using a PCB which makes your project less prone to failure and can last for years if you use good quality components beside a good quality PCB.
Circuit description:
The circuit consists of four essential parts:
Let’s see each one of the one by one.
DFplayer Mini:
DFplayer mini is a small inexpensive module that is capable of playing MP3 and WMV files from an SD card with good audio quality and loudness. Despite its size and cost, it has very decent specifications for a music player as follows:
Pin diagram of DFplayer:
Let’s explore the following pins on this module as we will be using only these pins: Vcc, GND, TX, RX, SPK1, SPK2, DAC_R, DAC_L and busy.
Vcc and GND are power input pins. TX and RX pins are used for sending and receiving data for controlling this module respectively, RX pin must be connected to a 1K ohm resistor as Arduino’s serial output is at 5V level, and RX pin of DFplayer is NOT 5V tolerant.
The pins SPK1 and SPK2 are the speaker output pins, you can connect speakers up to 3 watt maximum with 4 ohm coil resistance or above. You can connect mono or stereo speakers, in case of mono (single) speaker connect your speaker across SPK1 and SPK2; in case of stereo (two) speakers connect one of your speakers to SPK1 and GND and another one to SPK2 and GND. If you wish to connect external amplifiers use DAC_R and DAC_L pins.
The busy pin turns LOW when a track is playing and turns HIGH when no track is being played.
The RTC / Real Time Clock Module:
The RTC module is the one which keeps track of time accurately even when you disconnect the power from the main circuit. The RTC module has its own backup battery (lithium cell) which usually lasts 2 years or more.
We are utilizing a DS3231 RTC module which is illustrated in the above image, however you can also use DS1307 RTC but the accuracy of the time tracking will be far less, with our testing with multiple DS1307 modules it was drifting few minutes in the first week of usage (which is bad), but using DS3231 we did not notice any significant drifting of time, so we recommend you to use DS3231.
LCD display:
Here we are using a standard 16 x 2 LCD (Blue / Yellow) for displaying information. We are using this LCD in 4-bit mode and no display I2C module is used here. You can adjust the LCD contrast using the provided 10K potentiometer.
Arduino:
Arduino is the brain of this project which controls the display, DFplayer, acquires correct time from RTC and also the one which takes input from the user via push buttons and stores in its built-in EEPROM memory which is non-volatile.
You can choose any Arduino board of your choice, our recommendation is Arduino Nano so that it can be built compactly and prototyping on a breadboard is much easier.
Power supply:
To power this circuit you will need a 9V to 12V (500mA minimum) wall adapter and no batteries will be used (except for the RTC). We have utilized 7805 voltage regulator which outputs a constant 5V to Arduino and also for other peripherals.
Prototype of MP3 digital alarm clock:
How to set correct time to the machine:
1) Press setting button twice and you see the following screen:
2) Press enter to move inside this setting.
3) It will request you to set hours, use INC (increment) or DEC (decrement) buttons to set the correct hour and press enter to move on to minute setting.
4) Similarly use INC and DEC buttons to set correct minute and press enter, (If you want to go back to the hour setting press back button once).
5) After you set the minute and press enter, the time will be saved to RTC and the LCD will say “TIME SAVED”.
6) The display will return to home screen / idle screen.
How to set date to the machine:
1) Press setting button thrice and you will see the following screen
2) Press enter and it will request you to set day, use INC and DEC buttons to set the correct day and press enter to move to the next date setting.
3) Now the screen will ask you to set date from 1 to 31, set the correct date using INC and DEC buttons and press enter.
4) Next the screen will ask you to set month, use INC and DEC buttons to set the correct month and press enter.
5) Finally, the screen will ask you set years, use INC and DEC buttons to select the current year and press enter and the date will be saved to RTC and the screen will say “DATE SAVED” and returns to home screen.
6) Please note that you may press back button to move a step or multiple steps back (before you hit save) and correct an incorrect setting.
How to set alarm:
Note: You need to set the correct date and time before you set an alarm.
1) Press setting button once and you will see the following screen:
2) Press enter to move inside this setting.
3) You will see the following screen:
On the top left, you will see alarm number 1 to 5, on the top right you’ll see alarm time that you have set (initially you will see 00:00). On the bottom left you will see the track number that you set for this alarm (say 01) and on the bottom right you will see the status of this alarm whether this alarm number is ON or OFF.
4) You may press INC button to move to alarm setting number 02 (till alarm no. 05) and see its user pre-set as shown above or you may press enter button to change settings of the above shown alarm number 01.
5) After you press enter at any alarm screen (1 to 5), it will ask to turn ON / OFF of that particular alarm. Press INC for ON and DEC for OFF and press enter. If you choose OFF the alarm will be turned OFF (without affecting other alarms) and goes to home screen. If you choose to ON the alarm, it will unfold the rest of the settings.
6) Next, it will ask you set a track number from your SD card, press INC / DEC to select a track number and press enter.
7) Next it will request you to set a volume level for playing the track that you have just selected. You can set a comfortable volume for your alarm song from 1 to 30 (volume level). Use INC / DEC to select a volume and press enter.
8) Next, it will ask you to set alarm time (hour), use INC / DEC to set an alarm hour and press enter.
9) Finally, the screen will ask you to set minutes, use INC / DEC to choose minute for your alarm and press enter. The alarm settings will be saved to EEPROM of Arduino and the screen will say “ALARM SAVED” and goes to home screen. Now when the set alarm time matches the current time it will play the full MP3 track at a volume you have set. If you wish to stop the alarm track that is being played press INC and DEC buttons simultaneously.
You will see the following screen when an alarm track is being played:
10) Please note that at any alarm setting stage (before you hit save) you may press back button to move a step or multiple steps back and make any changes to the alarm setting.
Note: The content and the pictures in this article are contributed by the author. The opinions expressed by contributors are their own and not those of PCBWay. If there is any infringement of content or pictures, please contact our editor (zoey@pcbway.com) for deleting.
Written by