Pages: [1]   Go Down
Author Topic: RTC DS-1307  (Read 726 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, My son and I are working on a project together and we are looking for some advice on how we could us the rtc1307 to turn on a light on a specific date and time. Like a calendar/appointment reminder. After an rtc read,  will the arduino keep up the time and date or do I have to continually execute the rtc read?

Thank you!!! smiley
Logged

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2805
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look at the Time library, it is used to keep the time in a sketch.
The RTC is only used now and then, at power up and maybe every hour or so.
This is set able in your sketch.
The Time library comes with examples that explain this.
Also look at TimesAlarms.

Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4335
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you want to know the current time you have to ask the RTC but this is as simple as using the hour() function.

You could do worse than search this forum for rtc1307  to find similar projects.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

0
Offline Offline
Sr. Member
****
Karma: 8
Posts: 291
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The time library works together with the rtc. The arduino keeps time but not accurately so it'll look at the rtc every 5 minutes or so to  sync itself. You also don't want to query the rtc every second either. It's a strain on the device so the time library is a happy medium.
Logged

Colorado, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been working with the DS3231 a little bit, which is a newer version similar to the DS1307. I understand the internal registers are a bit different between the 2 versions. http://datasheets.maximintegrated.com/en/ds/DS3231.pdf

At least in the 3231, you can set an alarm which can generate an output signal which you can connect to an Arduino. If the Arduino has to act immediately when the time comes, then you could program an interrupt service routine in the sketch and use an interrupt input pin. Otherwise feed a regular digital input pin on the Arduino, and let the sketch loop, reading the input over and over until it changes.

Except for setting the time, alarm(s), and registers in the 1307/3231, you almost don't need the Arduino.
« Last Edit: April 01, 2014, 06:54:53 am by sellonoid » Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1926
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

For some info about using the 1307 and example code see the ArduinoInfo.Info WIKI HERE:
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the quick feedback. After looking through some of the examples...It looks like the TimeAlarms example is what fits what I am looking for. Instead of typing a time to set, I would like it to read the RTC and load it's values. I think I have that figured out but, I don't see a way to set the day of week(Saturday,Sunday). Any one tackle this before?

Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4092
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been working with the DS3231 a little bit, which is a newer, pin for pin compatible version of the DS1307.

It doesn't have the same number of pins, and doesn't come in the same packages, therefore I wouldn't call it pin-for-pin compatible.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Jr. Member
**
Karma: 0
Posts: 98
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the Time, DC1307RTC and timerAlarms libraries to achieve you goals.

You will see all the functionality examples required to get your project working within these libraries.

To answer one of your questions about making the arduino read the RTC for its time instead of having to specify a time, make the function call setSyncProvider(RTC.get); followed by setSyncInterval(60); during the setup().
This tells the arduino Time library (which is what the arduino will actually be referring to for time calls) that it is to sync its time with the RTC upon start up and then keep re syncing  its self with the RTC every 60 seconds. Feel free to experiment with changing the re sync intervals. I find 60 seconds to work fine.

Another thing, I would recommend against the use of the DS1307 as a RTC as it can barley keep the time to 1 minutes over a day. Its very much temperature dependant on how accurate its time keeping is.  Instead, get the DS3231 RTC which is tempertaute compinsated and compatible with the DS1307 library and is good for around a minute or two a year.... and maybe $1 more in price. I swear by the DS3231 RTC.
Logged

Colorado, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been working with the DS3231 a little bit, which is a newer, pin for pin compatible version of the DS1307.

It doesn't have the same number of pins, and doesn't come in the same packages, therefore I wouldn't call it pin-for-pin compatible.
You are right. Sorry for the misinformation. I edited my original post.
« Last Edit: April 01, 2014, 06:55:33 am by sellonoid » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 107
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Instead, get the DS3231 RTC which is tempertaute compinsated and compatible with the DS1307 library and is good for around a minute or two a year.... and maybe $1 more in price. I swear by the DS3231 RTC.
My experience is that the DS3231 is considerably more expensive than the 1307--Mouser lists the 1307 for $3 each (qty 1), while the 3231 is about $9 each.  The improved accuracy is nice, though, as is the lower parts count to support (no crystal needed).
Logged

Oregon, USA
Offline Offline
Edison Member
*
Karma: 69
Posts: 2381
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you can wait a couple of weeks for shipping, dx.com has cheap DS3231 boards: http://www.dx.com/p/high-accuracy-ds3231-module-w-temperature-battery-blue-168974#.UzsWCqIxZjs
Logged

"It seems to run on some form of electricity"

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Complete DS3231 modules with batteries are available on Ebay starting at under $3 USD.

I'm using a few of them.
Just be careful, on some of them you must cut a trace as most of the use a circuit
that was designed for a rechargeable battery and a normal 2032 are is meant to be charged.

They have a resistor and diode going from VCC to the battery.
Just cut the trace from the diode to the battery to disable
the charging. It is a very quick and easy mod.


--- bill
« Last Edit: April 01, 2014, 03:46:27 pm by bperrybap » Logged

Oregon, USA
Offline Offline
Edison Member
*
Karma: 69
Posts: 2381
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some of those cheap ebay DS1307 modules also have a resistor going from Vcc to the crystal. See this link for a schematic diagram http://www.hobbyist.co.nz/sites/default/files/docs/RTC/Tiny_RTC_schematic.pdf
This is an extremely bad idea as power supply noise is known to seriously compromise the time-keeping accuracy of the DS1307. Finally, Dallas Semiconductor warns against having anything between the battery and Vbat, so in addition to removing the diode, short out R6 and remove R4 and R7 (see schematic diagram).
Logged

"It seems to run on some form of electricity"

Pages: [1]   Go Up
Jump to: