Arduino Forum

Using Arduino => Sensors => Topic started by: djm2 on Dec 13, 2012, 11:00 am

Title: Date and time with DS1307
Post by: djm2 on Dec 13, 2012, 11:00 am
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
Title: Re: Date and time with DS1307
Post by: Riva on Dec 13, 2012, 11:13 am
What library are you using to access the DS1307? I use RealTimeClockDS1307 https://github.com/davidhbrown/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.
Title: Re: Date and time with DS1307
Post by: djm2 on Dec 13, 2012, 12:17 pm
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
Title: Re: Date and time with DS1307
Post by: Riva on Dec 13, 2012, 12:45 pm

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()