Go Down

Topic: RTC DS-1307 (Read 919 times) previous topic - next topic

Bwester

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!!! :)

LarryD

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.

The way you have it in your schematic isn't the same as how you have it wired up!

UKHeliBob

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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

mistergreen

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.

sellonoid

#4
Mar 31, 2014, 03:12 pm Last Edit: Apr 01, 2014, 01:54 pm by sellonoid Reason: 1
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.

terryking228

For some info about using the 1307 and example code see the ArduinoInfo.Info WIKI HERE:
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Bwester

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?


Jack Christensen


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.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Horendus

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.

sellonoid

#9
Apr 01, 2014, 01:53 pm Last Edit: Apr 01, 2014, 01:55 pm by sellonoid Reason: 1


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.

danb35


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

jremington

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

bperrybap

#12
Apr 01, 2014, 09:41 pm Last Edit: Apr 01, 2014, 10:46 pm by bperrybap Reason: 1
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

jremington

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

Go Up