DS1307 RTC resetting unexpectedly

Thought you have probably tested with all the DS1307 libraries you could find I use this GitHub - davidhbrown/RealTimeClockDS1307: Yet another DS1307 Real-Time Clock library for Arduino (obsolete) for my DS1307 RTC (see the examples) and it works fine on my UNO. As you said the SDA & SCL lines are on mega pins 20 & 21.