Hopelessly confused by Chronodot time setting

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
GVeers
 
Posts: 7
Joined: Wed Feb 12, 2014 10:25 pm

Hopelessly confused by Chronodot time setting

Post by GVeers »

Hi all,

I'm trying to set my Chronodot 2.1 with the correct time. I understand I'm supposed to follow the instructions here:

http://learn.adafruit.com/ds1307-real-t ... g-the-code

A couple issues I encounter out of the gate:

- it says to turn the datalogger shield on. Is this a separate chip? I'm running a Teensy 2.0 and can't seem to find this option. Is it necessary to program the clock?

- my default code in ds1307 is slightly different from the example; the RTC.adjust line is not commented out by default. I would think this could cause the line to execute every time I run my primary sketch, thus resetting the clock. Why is it commented out in the example but not in the library I downloaded?

- when I run ds1307 (or a variation where the if statement surrounding the RTC.adjust is remove, as the tutorial suggests), the clock does not program to the current date/time. My process is to reset the battery, upload ds1307, disconnect power, upload my sketch, reconnect power and check the clock. It's always at 1/1/2000.

I thank you for any input you can offer.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Hopelessly confused by Chronodot time setting

Post by adafruit_support_mike »

GVeers wrote:it says to turn the datalogger shield on. Is this a separate chip? I'm running a Teensy 2.0 and can't seem to find this option. Is it necessary to program the clock?
The "turning the datalogger on" part makes more sense in the context of the part just before that: remove the battery from the dataloggeer (or in this case the Chronodot) and disconnect all other sources of power. That's the definition of "off", and you need to keep the RTC that way for at least three seconds for it to lose any time settings you may have given it already. "On" means connecting the RTC to a source of power again.
GVeers wrote:I would think this could cause the line to execute every time I run my primary sketch, thus resetting the clock. Why is it commented out in the example but not in the library I downloaded?
It does, and that's generally desirable. It basically syncs the clock with your computer every time you program it. The only situation where it causes trouble is when you load a program that sets the clock, disconnect the Arduino from your computer and let it run for a while, then reset the Arduino. That will execute the programmed setup() function again, setting the clock back to the time when you last programmed the Arduino.

In general you want to run a simple sketch that sets the RTC once, then comment that line out when loading the code that will run for a long time, and might experience resets.
GVeers wrote:when I run ds1307 (or a variation where the if statement surrounding the RTC.adjust is remove, as the tutorial suggests), the clock does not program to the current date/time. My process is to reset the battery, upload ds1307, disconnect power, upload my sketch, reconnect power and check the clock. It's always at 1/1/2000.
- Remove the battery and disconnect the Chronodot from all sources of power.
- Leave it that way for at least three seconds.
- Put the battery back in and connect the Chronodot to your Teensy.
- Uncomment the line that sets the time.
- Upload the sketch.
- Comment out the line that sets the time.
- Upload the sketch again.

That should set the clock once, then let the Chronodot keep its own time afterwards.

GVeers
 
Posts: 7
Joined: Wed Feb 12, 2014 10:25 pm

Re: Hopelessly confused by Chronodot time setting

Post by GVeers »

Thanks for the reply, Mike! As it turns out I was able to resolve my problem, but your post was informative and helpful regardless.

It turns out I was using a different RTClib from the version that is linked to on the Chronodot page. Further confounding things, my sketch would not compile with the new RTClib, but only with an older version I found (perhaps because the sketch is from 2012?)

In any event I was able to write the time with the new RTClib following the instructions here:

http://forums.adafruit.com/viewtopic.ph ... 3&start=17

I then replaced the RTClib with the previous version and uploaded my sketch. It was very convoluted but I'm just happy it works!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”