In this Arduino Project video, we are going to build a Real Time clock using the DS1302 RTC module and my favorite Arduino display, the Nokia 5110 LCD display. The project is super easy to build so it is ideal for beginners in Arduino. It won’t take you more than five minutes to build. Let’s get started!

Intro to the Arduino Real Time Clock project

All we need is a DS1302 real-time clock module which costs around 2 euros. We need a Nokia 5110 LCD display which costs around 2.5 euros and of course an Arduino of your choice. That costs from 2 to 15 euros. We are going to use an Arduino Mega today. So you can build this project for as low as 7 Euros. But let’s start. First, let’s take a look at the DS1302 real time clock module. It is a very simple and low-cost module which consists of the DS1302 chip, a crystal and of course a battery in order to keep time. This module can keep time for years with this battery.

——————–
WHERE TO BUY
——————–

1. DS1302: https://educ8s.tv/part/DS1302

2. Nokia 5110 LCD: https://educ8s.tv/part/NOKIA5110

3. Arduino Uno: https://educ8s.tv/part/ArduinoUno

4. Small Breadboard: https://educ8s.tv/part/SmallBreadboard

5. Wires: https://educ8s.tv/part/Wires

Full disclosure: All of the links above are affiliate links. I get a small percentage of each sale they generate. Thank you for your support!

[adsense]

We have to connect 5 pins in order to make it work. The first pin of the module is named Vcc. VCC goes Arduino 5 Volts. The second pin is Ground. Ground goes to Arduino Ground. The third pin is Clock and we connect it to digital pin 7 of the Arduino. The fourth pin is named DAT from Data and we connect it to digital pin 6 of the Arduino. The fifth pin is named RST. We connect RST at digital pin 5 of Arduino. Of course, you can attach those pins at any digital pin you like but then you will have to change them in the code as well. In order to see how to connect the Nokia 5110 LCD display check out the tutorial that we have prepared for that.

——————–
LIBRARIES
——————–

? DS1302 Library: https://github.com/msparks/arduino-ds1302

? Nokia 5110 Library: http://www.rinkydinkelectronics.com/library.php?id=47

Now let’s go to the computer and see how to program this real-time clock. In order to use the DS1302 real-time clock module we first have to download the appropriate library. it is the msparks library from GitHub. You can find the link for this library in the description of the video. Then we have to unzip the library to Arduino -> Libraries folder. We unzip it in Arduino -> Libraries folder and we rename it to something more easy like DS1302. That’s it. Now we can use it in our project. I have loaded today’s project that consists of two files. The code and the data for the clock icon that appears in the display when the program is first loaded. we have made another tutorial about loading graphics in the Nokia 5110 LCD display so check it out first.

The Code of the Arduino Real Time Clock Project

The first time that you run this program you have to set time to the module. You have to go to the setTime function and change this line here to reflect current date and time. The first argument is the year, the second is the month the third is the day, the fourth is time, the fifth is minutes and the sixth is seconds. Then you have to enter the day of the week kThursday is for Thursday kMonday and so on for the other days of the week. Be careful though in this example the time is 13:09 but we don’t enter 09 here because it won’t work we enter 9. As it is for the month as well. We don’t enter 02, we enter only 2 for months. It is the same for hours. If it was 9 in the morning we don’t enter 09 we just enter 9. So the time now will be like this. Now we compile and run the program only once. When the program will run in the Arduino it will set the time. Next, we have to comment this line here because we don’t want to set time, each time the program is loaded but only the first time. So we comment this line and we run the program again. Now we are ready to use the code and make any changes that we like. The program prints time every second. It’s very easy and straightforward. You can download it from the link below. That’s how easy it is to build a real-time clock. I hope this video will be helpful. If you have any comments or questions post them in the comments below.

——————–
CODE
——————–

 

 

 

——————–

SUBSCRIBE ON YOUTUBE

——————–

Never miss a video: Subscribe to educ8s.tv