I've written a header file/library/examples for the DS3231 clock: it's available here:
I wrote it for the DS3231, but the timekeeping registers are identical on the DS3232 so it'll work for that also.
This forum has been incredibly helpful to me over the years, and I hope this is a start on repayment. Drop me an email if you use it, and let me know if you find bugs so I can fix them right away.
As it turns out i ran into the same issue with the 1.0 ide and ended up updating it myself.
I ran the examples and they seem to work just fine.
i do not know if you already updated the code or not but here is the a copy of the files i updated.
The example codes remains unchanged but is now in an ino file.
Your orig lib and examples helped me understand how to get this IC up and running for my datalogger.
I have found a few of your sketches to be rather helpful.
Thank you
I set my clock with the example in the zip, and when I run the example test for some reason one time is exactly 6 hours off of the other. The logs look like:
It appears from my tests that getHour() is returning the proper hours, but getTime() is not, looking at the code and there didnt seem to be any glaring differences though, any local pros have an idea?
// Display the time > getTime() function
Clock.getTime(year, month, date, DoW, hour, minute, second);
if (month < 10)
{
Serial.print("0");
Serial.print(month, DEC);
}
else
{
Serial.print(month, DEC);
}
Serial.print("/");
if (date < 10)
{
Serial.print("0");
Serial.print(date, DEC);
}
else
{
Serial.print(date, DEC);
}
Serial.print("/");
Serial.print("2");
if (Century)
{ // Won't need this until 2100 - or if clock gets reset.
Serial.print("1");
}
else
{
Serial.print("0");
}
if (year < 10) // used if the clock gets reset or if the year is 2100 - 2110
{
Serial.print("0");
}
Serial.println(year);
Serial.print("day of the week : ");
Serial.println(DoW, DEC);
if (hour <10)
{
Serial.print("0");
Serial.print(hour, DEC);
}
else
{
Serial.print(hour, DEC);
}
Serial.print(":");
if (minute < 10)
{
Serial.print("0");
Serial.print(minute, DEC);
}
else
{
Serial.print(minute, DEC);
}
Serial.print(":");
if (second < 10)
{
Serial.print("0");
Serial.println(second, DEC);
}
else
{
Serial.println(second, DEC);
}
// simple way to format the output to include the leading zeros.
// with adjustments for formatting the year if clock gets reset or year 2100+
// NewAgeRyan85
I see that the last post was a little over a year ago. has this code been fully fleshed out? Or will I need to apply the above corrections to the code? And I am a bit confused as to which header file to download.