How do I get my RTC ds3231 off of January 1st 2000

I cannot seem to use Eric ayars' DS3231 library to work when programming my ds3231

Please post the code that you are trying and a link to the library

Link to the library.

And here's a link to the code on GitHub.

fylkir:
I cannot seem to use Eric ayars' DS3231 library to work when programming my ds3231

So what happens when you run the example ?

What should it do and what does it do ?

Sorry for the late response.

It uploaded the code fine.

It's supposed to program the time to today's date. It doesn't when I do what it tells me to do.

Did you edit the code and change the date to upload to today's date? Or just upload it as is?

Yes. I changed the date to reflect current time and date.

Why are you not following the website’s posting guide lines?

Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]

I'm away from the computer that I have the code on. I'll be at it in about 4 hours. I'm travelling.

[code]
/*
DS3231_set.pde
Eric Ayars
4/11
Test of set-time routines for a DS3231 RTC
*/

#include <DS3231.h>
#include <Wire.h>

DS3231 Clock;

byte Year;
byte Month;
byte Date;
byte DoW;
byte Hour;
byte Minute;
byte Second;

void GetDateStuff(byte& Year, byte& Month, byte& Day, byte& DoW, 
    byte& Hour, byte& Minute, byte& Second) {
  // Call this if you notice something coming in on 
  // the serial port. The stuff coming in should be in 
  // the order YYMMDDwHHMMSS, with an 'x' at the end.
  boolean GotString = false;
  char InChar;
  byte Temp1, Temp2;
  char InString[20];

  byte j=0;
  while (!GotString) {
    if (Serial.available()) {
      InChar = Serial.read();
      InString[j] = InChar;
      j += 1;
      if (InChar == 'x') {
        GotString = true;
      }
    }
  }
  Serial.println(InString);
  // Read Year first
  Temp1 = (byte)InString[0] -48;
  Temp2 = (byte)InString[1] -48;
  Year = Temp1*10 + Temp2;
  // now month
  Temp1 = (byte)InString[2] -48;
  Temp2 = (byte)InString[3] -48;
  Month = Temp1*10 + Temp2;
  // now date
  Temp1 = (byte)InString[4] -48;
  Temp2 = (byte)InString[5] -48;
  Day = Temp1*10 + Temp2;
  // now Day of Week
  DoW = (byte)InString[6] - 48;   
  // now Hour
  Temp1 = (byte)InString[7] -48;
  Temp2 = (byte)InString[8] -48;
  Hour = Temp1*10 + Temp2;
  // now Minute
  Temp1 = (byte)InString[9] -48;
  Temp2 = (byte)InString[10] -48;
  Minute = Temp1*10 + Temp2;
  // now Second
  Temp1 = (byte)InString[11] -48;
  Temp2 = (byte)InString[12] -48;
  Second = Temp1*10 + Temp2;
}

void setup() {
  // Start the serial port
  Serial.begin(9600);

  // Start the I2C interface
  Wire.begin();
}

void loop() {

  // If something is coming in on the serial line, it's
  // a time correction so set the clock accordingly.
  if (Serial.available()) {
    GetDateStuff(Year, Month, Date, DoW, Hour, Minute, Second);

    Clock.setClockMode(true);  // set to 24h
    //setClockMode(true); // set to 12h

    Clock.setYear(2020);
    Clock.setMonth(1);
    Clock.setDate(9);
    Clock.setDoW(5);
    Clock.setHour(7);
    Clock.setMinute(05);
    Clock.setSecond(0);

    // Test of alarm functions
    // set A1 to one minute past the time we just set the clock
    // on current day of week.
    Clock.setA1Time(DoW, Hour, Minute+1, Second, 0x0, true, 
      false, false);
    // set A2 to two minutes past, on current day of month.
    Clock.setA2Time(Date, Hour, Minute+2, 0x0, false, false, 
      false);
    // Turn on both alarms, with external interrupt
    Clock.turnOnAlarm(1);
    Clock.turnOnAlarm(2);

  }
  delay(1000);
}

[/code]

What are you entering in the Serial Monitor?

Why are you doing this, over and over?

    Clock.setYear(2020);
    Clock.setMonth(1);
    Clock.setDate(9);
    Clock.setDoW(5);
    Clock.setHour(7);
    Clock.setMinute(05);
    Clock.setSecond(0);

Why are you doing this, over and over?

It's actually contained in a Serial.available() conditional which can also hang up on a while (!GotString) statement.

It's not clear to me that its even done once. :frowning:

How would you go about doing this?

Follow the library example as written. Why did you decide to add fixed values into the fields which are designed to be filled from the GetDateStuff() function after entry from the Serial Monitor?

The stuff coming in should be in the order YYMMDDwHHMMSS, with an 'x' at the end.