And an example that just sets the time on the chip and then reads it and outputs it in the serial monitor window.
The library seems to successfully read the time from the chip but it doesn't set it successfully. It seems to be set at some default value from the time of manufacture perhaps.
Has this problem been encountered previously and covered? If so what is the solution?
I have 2 sketches: one simply sets the time. I hardcoded the time into the sketch, a few minutes ahead. Then I compile and upload, which of course sets the time fast and I view that in monitor. I watch the clock on my pc, and restart the monitor at the appropriate time which resets the sketch and sets the correct time. The sketch then sets the rtc to read only.
Then in my other sketch, the "real" one, I only read the time. You can see my time as published by my Arduino web server here, although our ADSL is a bit dodgy in the storms we've been having.
Look at this: Ways to update the RTC DS3231 from NTP server (the code is compatible with a wide range of RTC chips DSxxxx). The source code does not use RTC library. The program communicates directly with the RTC chip. It is very easy to take the part, adapt and use (see set_rtc_datum and set_rtc_time).