I am trying to set the date & time to DS3231 using library from Makuna
It is unrealistic to expect us to hunt for the library you are using, so we can look at the header file for you.
Print the values of DATE and TIME, and it should be pretty obvious how to construct a date string and a time string that contains the time you want to set.
Bronson_alex:
But how can I set the date time manually? So the user can set the date time using keypad + lcd display.
What type of "keypad"?What type of LCD?
The easiest programming logic would require three function keys: - Select/Up/Down
Then I'd use the "Select" key to switch modes
normal mode (date/time display only)
year adjust mode(user can change year)
-month adjust mode(user can change month)
-day adjust mode(user can change day)
-hour adjust mode(user can change hour)
minute adjust mode(user can change minute)
In the "normal mode" the Up/Down keys would have no effect when pressed
And in the "adjust modes", pressing Up/Down would adjust the selected unit either up or down
That's a simple and straight-forward programming logic.
Simply check for pressed keys about500 times per second,
update RTC after any change of year/month/day/hour minute
update display after RTC had a change or after one second has passed since last LCD update
Instead of three button keys it would also be possible to use one "rotary encoder with switch" instead to set date/time
PaulS:
It is unrealistic to expect us to hunt for the library you are using, so we can look at the header file for you.
Print the values of DATE and TIME, and it should be pretty obvious how to construct a date string and a time string that contains the time you want to set.
Thx for the reply,PaulS.
Pls don't misunderstand, I don't expect anyone to look at the header file for me as I believe that DATE and TIME constants are not header related.
As you said, I just don't know how to construct/convert my_date and my_time string variables to DATE and TIME format. Are they just simple strings or array of char?
Thanks! Bookmarked!
I might need it in the future.
In fact, I have solved my problem. It appears that DATE and TIME are just simple Strings. No need to convert anything.
I can just do:
RtcDateTime manual = RtcDateTime("Jan 25 2017", "16:30:00");
Rtc.SetDateTime(manual);