Trying to get a DS3231 RTC working on a Arduino Mega.
Most sketches just display a series of "squares" on the serial monitor.
Have tried a few different sketches but all print "Squares" on the monitor when days, hours.minutes and seconds are expected.
Have tried several different RTC's and jumper wires and pretty certain wiring is correct.
Any suggestions?
I have found one that works perfectly & it must also automatically input correct Y, Mo, D, Mi &S as it required no inputs from me to establish these values.
Except it prints the year as 1918 instead of 2018.
I can find this section of code which seems to relate to " setting time" but cannot get it to work for me.
void parse_cmd(char *cmd, int cmdsize)
{
uint8_t i;
uint8_t reg_val;
char buff[BUFF_MAX];
struct ts t;
//snprintf(buff, BUFF_MAX, "cmd was '%s' %d\n", cmd, cmdsize);
//Serial.print(buff);
// TssmmhhWDDMMYYYY aka set time
if (cmd[0] == 84 && cmdsize == 16) {
//T355720619112011
t.sec = inp2toi(cmd, 1);
t.min = inp2toi(cmd, 3);
t.hour = inp2toi(cmd, 5);
t.wday = cmd[7] - 48;
t.mday = inp2toi(cmd, 8);
t.mon = inp2toi(cmd, 10);
t.year = inp2toi(cmd, 12) * 100 + inp2toi(cmd, 14);
DS3231_set(t);
Serial.println("OK");
Appreciate any suggestions on how I can change it to output the correct year?
rtc_ds3231.ino (4.52 KB)