Go Down

Topic: Date and time with DS1307 (Read 479 times) previous topic - next topic

djm2

Hi there

I have a DS1307 connected up to my Arduino which is working great.  I can read the time from it and write to it.

From the DS1307 I get the date and time.  Does anyone know how to get which day it is?  ie the DS1307 knows that today is the 13th but can it also tell me that today is a Thursday?

David

Riva

What library are you using to access the DS1307? I use RealTimeClockDS1307 https://github.com/davidhbrown/RealTimeClockDS1307 and it has a getDayOfWeek() to access the DAY register (3) on the DS1307. Most other libraries will probably have a similar function. Note that you need to set the DAY register correctly when setting the date & time. It is not a calculated value from the date but just a counter that counts from 1 to 7 and then resets back to one. This allows you to use what ever value you want (between 1 and 7) as the first day of the week.
http://forum.arduino.cc/index.php?action=unread;boards=5,67,10,11,66,12,15,17,21,22,23,24,25,29;ALL

djm2

Hi there

I am using the library from Ladyada - http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html

But it does not seem to have that function.

David

Riva


I am using the library from Ladyada - http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
But it does not seem to have that function.

For that library I think you use dayOfWeek()
http://forum.arduino.cc/index.php?action=unread;boards=5,67,10,11,66,12,15,17,21,22,23,24,25,29;ALL

Go Up