Help with RTC Clock module!!!

I have got an RTC clock module, but I have some problems with it that I need some help with. I have conect it up to the Arduino there SDA pin is on A4 and SCL on A5. I use the libary RTClibmaster, and a exemple from there to set the time and date. I wrote a little code to get the time on a LCD screen, but the problem is when I set the time it is 20-30 second to late, and when it pase 59 second it is started to count 10,20,30,40,50,60,70,80,90 and after that it started to count normaly again 1,2,3,4...... on the second. So the last problem is that it wount remember the time when I shutdown the power, when I cut the power and put it back on it start the time from there it started the time last time I upload the code, it will not remeber. I have tested the conection to the battery, and the battery is 100% new. Please help me, I have a plan to make something fun with it and that is not so easy when it wont work :)

Thanks!!! :) PS: Sorry for my bad english :)

Which RTC module? With a coin battery? Does it have pull-up resistors built in?

The module is an Tiny RTC I2C I have trayd batery "LIP2032" and "CR2032" but non of them worked. I'm not sure on what the pull-up resistors is, but if it is that I think it is, the little shiny metal thing then yes, else i don`t now :)

but the problem is when I set the time it is 20-30 second to late

So, there is something wrong with your code. Fix it.

and when it pase 59 second it is started to count 10,20,30,40,50,60,70,80,90

It most definitely does not. You just aren't overwriting the 0 on the end when you display (incorrectly, obviously) the new value.

The values should be displayed like: 12:30:58 12:30:59 12:31:00 12:31:01

Not 12:30:58 12:30:59 12:31:0 12:31:1 (which I'm sure, without even seeing your code, is what you are doing.)

You have so right :slight_smile:

My code is:

#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>

RTC_Millis rtc;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup () {
    rtc.begin(DateTime(__DATE__, __TIME__));
    lcd.begin(16, 2);
}

void loop () {
    DateTime now = rtc.now();
    
    lcd.setCursor(0,0);
    lcd.print(now.hour(),DEC);
    lcd.print(":");
    lcd.print(now.minute(),DEC);
    lcd.print(":");
    lcd.print(now.second(),DEC);
}
    rtc.begin(DateTime(__DATE__, __TIME__));

So, you start the upload process. The IDE does some stuff, invokes the preprocessor, which defines the string TIME. Then, the compiler is called, and the linker. When the linker is done, it calls avrdude to upload the hex file to the Arduino. The board resets, then the bootloader notices that there is a sketch to be uploaded, so it erases the board, and accepts the new sketch. Then, the Arduino resets, and the new sketch starts running. And, you wonder why that can take 20 seconds?

Of course!! You have so right :) :) But why will it not save the time in the module?? :) :) :) :) :)

It does save the time/date and I'm sure that it updates them when your Arduino in fact the RTC is working just as it should. However every time you execute setup() you over write the time/date LOOK AT YOUR CODE AND THINK!.

Mark