Build a Simple Alarm Clock with Arduino and DS1302 RTC

13 May 2023 Balmiki Mandal 0 µC - µP

Creating a Simple Alarm Clock with the DS1302 RTC

Every day, we rely on our alarm clocks to help us wake up in the morning and stay on track with our daily schedules. To make sure an alarm clock works accurately and reliably, it needs to be powered by an real-time clock (RTC). One popular RTC chip used in alarm clocks is the DS1302 from Maxim Integrated.

In this tutorial, we will show you how to create a simple alarm clock using the DS1302 RTC. We will also go over the basics of setting up the chip, understanding its various modes, and programming it for our specific application.

Components Needed

  • Arduino UNO
  • DS1302 RTC Module
  • 16x2 LCD Display Module
  • 2 Push Buttons
  • Buzzer
  • Jumper Wires

Setting up DS1302

The DS1302 is a low-power clock/calendar with real-time clock (RTC) and trickle-charge timekeeping. It provides second, minute, hour, day, date, month, and year information. The clock operates in either 24-hour or 12-hour format with selectable of AM/PM indication.

Before we can start programming, we need to first set up the DS1302 as shown in the circuit diagram below:

DS1302 Circuit Diagram

Connect the DS1302 module to the Arduino UNO using the following pins:

  • DS1302 SDA pin to Arduino A4 pin
  • DS1302 SCL pin to Arduino A5 pin
  • DS1302 RST pin to Arduino Digital Pin 8
  • DS1302 GND pin to Arduino GND Pin
  • DS1302 VCC pin to Arduino 5V Pin

Programming the Alarm Clock

Now that the hardware is set up, we can move on to the coding part. We will be using the Arduino IDE and the Time library to write the code for our alarm clock.

We will start by setting up the variables and defining the pins used to control the LCD, buzzer and buttons. Then, we will write the functions to read and write data from the DS1302 module and use it to display the current time and date on the LCD.

Finally, we will write the code for setting up the alarm and detecting when the time matches the alarm time. When the time matches the alarm time, the buzzer will turn on and the LCD will display the message “wake up!”.

Testing the Alarm Clock

Once the code is uploaded to the Arduino, the alarm clock should be ready for testing. Use the buttons to set the time and date and then set the alarm time. When the time matches the alarm time, the buzzer should sound and the LCD should display the “wake up!” message.

That's it! You've successfully created your own alarm clock using the DS1302 RTC!

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.