if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
When I originally did the project, I did not program the DS3231. The compiler was happy and everything worked. However because of the clock not remembering the time after it was powered off I assumed the DS3231 needed programming also. So I did that. Ever since I programmed the DS3231 the compiler lists lots of faults, such as the above.
Because of this, if I were to put the current time and date into the IDE to program it, it wont do it, because it now lists lots of faults.
I appreciate your rep[ly Kolaha, and I can now see the format that I set the date and time. I thank you for that.
The compiler wont do it now though.
One solution I can think of is to be able to reprogram the DS3231 to how it was before, in a state of brand new. The other is to order another DS3231 and use that, and see if it then works with a manual time and date set, in the sketch. Which I assume it will.
It was because the clock didnt remember the time when switched off, and I assumed then that the DS3231 needed the DS3231 software to use the lithium battery. Ever since I did that the sketch lists lots of errors.
This is perhaps the main thing that its saying is wrong. I post a compiler error
Compilation error: 'DS3231 clock' redeclared as different kind of symbol
If I hadnt programmed the DS3231 with the DS3231 software, then setting the time and date with the IDE would likely work.
I think if I ordered another DS3231 and used that, it would work.
OK, but what exactly did you program into it ? I assume that it was the date and time and just possibly some alarms
You seem to have 2 separate problems with your current sketch
every time you run the sketch the date/time is set to the compile time but you only need to do that once. It has been explained how to do this in this topic
You have compilation errors cause by name clashes. Again, the solution has been explained
You are having problems because the compiler is using the wrong library. You need to find out which library is needed for your code, and remove any other libraries that have a file named "DS3231.h".