How to set time on the datalogging shield?

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
robertwrand
 
Posts: 22
Joined: Fri Jan 03, 2014 8:24 pm

How to set time on the datalogging shield?

Post by robertwrand »

I'd like to periodically correct the RTC time using data from the Adafruit Ultimate GPS, at the top of a minute (seconds equals zero). I found a suggested method for setting the RTC time as shown in the code below (GPS already defined, tested, and running perfectly). The code to set time on the RTC didn't work. Print after set attempt (date y/m/d h:m:s, GPS is UTC, RTC not matching):

GPS: 14/7/20 17:42:00
RTC: 2014/7/14 11:30:0

Any suggestions?


#define USE_DS1307 1 // set nonzero to use DS1307 RTC
...
RTC_DS1307 RTC; // define the Real Time Clock object
...
// SET UP RTC (Real Time Clock DS1307)
Wire.begin();
if (!RTC.begin())
{
Serial.println("RTC failed");
};
...
Wire.beginTransmission(0x68); // activate DS1307
Wire.write(0); // where to begin
Wire.write(0x00); //seconds
Wire.write(GPS.minute); //minutes
Wire.write(0x80 | GPS.hour); //hours (24hr time)
Wire.write(0x01); // Day 01-07 -- ADAFRUIT GPS DOES NOT PROVIDE DAY OF WEEK
Wire.write(GPS.day); // Date 0-31
Wire.write(GPS.month); // month 0-12
Wire.write(GPS.year); // Year 00-99
Wire.endTransmission();

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: How to set time on the datalogging shield?

Post by Franklin97355 »

It would help if you posted your code in it's entirety. Please use the code button when posting code.
Code Button.jpg
Code Button.jpg (4.49 KiB) Viewed 346 times

User avatar
robertwrand
 
Posts: 22
Joined: Fri Jan 03, 2014 8:24 pm

Re: How to set time on the datalogging shield?

Post by robertwrand »

The code at http://bildr.org/2011/03/ds1307-arduino/ worked fine. All set.

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

Return to “Arduino Shields from Adafruit”