DS3232 RTC - cannot get this to work

Hi

(I’ve seen a number of posts with issues about this, but cannot find a solution which matches my problem, sorry if my question does, in fact, have a well documented solution)

I’ve been trying to get my head around this with a simple sketch before I try to incorporate it into bigger things - code pasted at end.

Many suggests involve using different libraries, and after testing several I’ve found this one does not actually give me any errors.

There are no errors at any stage, however the monitor just returns zeros, which the library documentation suggests is inability to see the RTC module. I’ve attached a screenshot of the monitor output

I’ve tried the IR2 test program from here, and it says it’s finding the device which suggests there isn’t a hardware fault

The code I’m using is below

// DS3232RTC - Version: Latest
#include <DS3232RTC.h>
#include <Wire.h>

DS3232RTC rtc;

void setup() {

Serial.begin(9600);
rtc.begin();

setTime(18, 34, 00, 13, 3, 2021);
rtc.set(now());

}

void loop() {

time_t myTime;
myTime = rtc.get();
Serial.print(time_t());

//Serial.print(rtc.get(hour))
Serial.print("\n");

delay(10000);

}

Any help with resolving this would be gratefully received

Best wishes
andy

Screenshot 2021-03-14 at 08.58.50.png

Which address was found by the I2C Scanner sketch ? Is it 0x68 ?

That library is used together with the TimeLib. Have you installed that ? I think that you have to call the setSyncProvider() function. Where did you find the example code ? it is for the Adafruit RTC library.

Is something else connected to your I2C bus ? Which Arduino board do you use ?

Thankyou :-)

I found and used the AdaFruit one, re-wrote the code, and it's working now.