hi welcome Turner doing a tutorial from Robojax. in this video we are
going to learn how we can use this D s130 seven clock module for Arduino display the
calendar including the year month day hour minute and day of weeks you can get the code
for this by clicking at the link below the video the description which will take you
to Robojax.com/learn/Arduino let's get started with this
this module is based on ds1 3:07 32 kilohertz clock counter and we're using the battery it
holds the time and date and updates continuously even if it is disconnected from power it holds
the full calendar including year month day hour minute and seconds and using those
parameters can control a device like turning it on and off based on certain data time for
example you can schedule a device to be turned on every day at 8 o'clock and turn off at 8:30
or a light or something to be turned on or a device based on some other trigger so this is
a very useful module it has broad application let me start by explaining the hardware after
that I am going to show you the wiring then I'm going to explain the code and
at the end I will demonstrate features of this and how to set the time and use it I will have
more videos related to this fake video to the spare time on LCD monitor harmony replication
when you receive that the when you receive this module most of the time that pins are
not connected it's called the pin header first and they're the panhead are on the breadboard
then put the module on top of the header and start soldering from one side to the
end till the type of chest did not have this battery the battery that you need is cr2032
this is a 3 volt lithium battery you can also connect the connectors either on this side if
you want I use the other side and then we have a actual chapter 50 SD one 3:07 chip and this
is a crystal of 32 kilohertz so this is a 32 kilohertz clock module make sure to use this
one with this code the job of this battery is to hold that time once the power is disconnected
from Arduino or the modulus it separates now with this battery the clock is now running and
it will not stay behind but once you remove it the time will be rosetted so whenever you remove
the battery you have to set the time which I'm going to show you in the code how to do that
let me explain the wiring this is D s the DF pin the second one the first one is left alone
not connected the S is connected to pin to happen to of Arduino and then here we have s
field these two SDA and SCL for I2C communication and Arduino SDA is 4 and SCL is a 5 using Arduino
Uno and then then SCL is a 5 and SDA a 4 and Arduino mega SDS 20 and then SCL is 21 and
Leonardo and all of those so you can connect a sphere to is the a SEL to SEL then we have
V CC VCC is connected using red wire to 5 volts and ground is connected to the ground of Arduino
let me explain the code the first thing that you need is to download the slide ready I will
provide you the link the wire is part of our ID you don't need to do it but this one you have
to download it unless you download it will be a zip file save it in your computer and
after that go to sketch include library add zip library and point it to the library for example
this is for another device just click to that zip file that you have downloaded and click open the
library will be included close your Arduino ide and reopen it this header file which is part of
the library inside this we have a class called RTC there's time clock d s130 7 and then we create an
object out of this class this is an object or instance of this class and this is day of week
this is a character of 7 item each with up to 12 characters day of the week as text you can see a
Sunday Monday Tuesday Wednesday all of them have been saved here then inside the setup we check
the serial if serial exists or is it possible because the others are do you know might not
have it if does not exist while means for Everest will be true and the table will not proceed then
we initialize the serial monitor with 9600 but using serial dot began this 9600 is the value that
is at the lower right corner of the screen when serial monitor and you can open serial monitor
by clicking here or by clicking at the tools and serial monitor then we check our TC dot begin this
is initially I think real-time clock this means if not if a is not true which is usually if it works
it will be true your apprentice and while one means stay forever and then is running there is
another function it is checking if it is running if there is not running it will print this error
do not worry about that and inside the loop here is the important part we initialize we are getting
the current time RTC dot now this is getting the current time from the clock module and is storing
it in a variable called now this is an object of date and time now that here comma decimal this is
a number it prints 2019 and the next line we print this forward slash and then we get the month as a
decimal 3 and then we put forward slash and after they open apprentice and then day of week this is
this is a number either 0 1 2 3 or 4 up to 6 and this number if we type here 5 for example if you
type here 5 it will go inside this array and get elements number 5 and the elements is here
this is 0 1 2 3 4 5 up to 7 and whatever day of week we have now that day of week will return a
number between 0 to 6 which is the of the week and then we converted to a text to print this
Monday for us and then we close it after that we said hours this is getting 21 which is my current
time and then we put Colin this Colin here to dot on top of each other and then 1 minute 40
and then repent second after that Ln this new line this goes to the next line and then friend's death
text the Unix time stamp this is a time stub that is widely used in the industry and it has started
from first month and from first day and first month of 1970 January 1st 1970 and since then
this many seconds have passed so these are number of seconds and then they put s for us and then
this 86,400 is number of seconds in a day 24 hours times 60 minutes times 60 second
is 86,400 and L refers to the datatype long future time for example current
time timespan and we can see seven days and 30 seconds from now future that ear
will get this calculation added to the current time that will give us a year
month and date the same as before including minute hour and second and trances like that
the demonstration as you can see this is now connected via USB and this is the time that you
are getting life if I disconnect this there's a scrolling of data that is coming we'll stop there
for not now scroll because the information is not coming if I connected and then close this and open
it again you will get the latest information from this and this was a information or data
that I have explained to you now I will remove the battery and show you that that time will be
reset it this is a bad battery that one terminal is in here the other terminal is in here when you
remove or work with this battery pay attention if this is one terminal and the positive is on
this side the negative is on this side and they have been separated with insulator in
here if your screwdriver somehow connects with both of these your battery will be discharged
immediately this is now a bad battery so I can do it no problem but for just battery now it's
very important that at the bottom I have to be careful but to remove the battery I just pull
this down and the battery went out now the clock is running properly I'm going to just
connect it and give it a few seconds the time should be reset it and now connecting it again
there is no battery let me close this and open it as you can see it shows that that time is here
2000 Saturday and it says it's not running because the battery is not there you see RCC is not
running and also a time is January 1st 2011 and second is zero zero zero now let me just invert it
and even if I open it again it will not be updated still this is an old time we have to
set the time now and here inside the setup I'm leaving this it says adjust you can do adjust
and put your own time whatever time you want the first one is this is year month day hour minute
seconds so this is an order from the largest unit to the smallest remember Monti is first
and days after that but if you want to get your system or your computer time just put this line
which is inside day of time there is an F and then F will use the left memory and then this
is the compiler date with to underscore this is one underscore another one date and then time
and let me uncomment this once you uncommented this is now connected upload the code now if
I open this you will see we are getting the current time from my machine here 21:55 and
it is the exact time after that when you see that time it said common death again and upload it now
this time it will just upload it because the battery is here it will hold the time
now it shows the time and even if I disconnect it close this wait and then connect it again
and just to open the serial monitor you will see that that time have been updated 21:56
that's that time thank you for watching if you learn from this please thumb up don't
forget that and also leaving the notification on and also subscribe so you can get updates
of my upcoming other videos the battery that you need is cr2032 this is a 3 volt
lithium battery you can also connect the connectors either on this side if you want
I use the other side it's up to you and then we have a actual chapter says the