I'm trying to implement a data logger with Date and Time needed using a DS1307. I want to use the PC time as my time source. So far it all works except the hours is 5 hours off.
Greenwich Mean Time (GMT) it looks like its following. My windows PC is correct.
Can you set the RTC manually? Your problem is that the time on your PC is altered by the time zone you are in. Knowing this, you can calculate what UTC is: manually set your clock once and as long as the backup battery lives, the RTC will maintain that time.
If you know the system clock is a set number of hours different from the compile time, you can modify the example sketch to adjust for this time. See the line I've added to set the clock 5 hours later than the compile time.
void setup() {
bool parse = false;
bool config = false;
// get the date and time the compiler was run
if (getDate(__DATE__) && getTime(__TIME__)) {
parse = true;
// and configure the RTC with this info
breakTime(makeTime(tm) + 60 * 60 * 5, tm); //add 5 hours to compile time
if (RTC.write(tm)) {
config = true;
}
}