RTC slows down after a few minutes and doesn't keep the correct time pace

Dabi_Aljv

New Member
Hello everyone.

I'm working on an automatic irrigation system using Arduino Mega 2560, TFT screen ILI9488, RTC module DS3231 and a KY-023 joystick module in a physical assembly (schematics are shown below).
1738284862518.png
Everything works fine. The problem is that the RTC doesn't keep the correct time. When the system is switched on, after a few minutes it starts to get delayed by seconds. The more time it is on, the more delay it gets. I'll leave the code I used here. It's a long code, mainly because of the screen part (it's also in Spanish, as it's my first language, you could ask some AI to translate the comments for you, sorry for that).

I would be very grateful for your help. Thanks in advance.
 

Attachments

  • Programador_de_Riego_ATmega328p.txt
    50.6 KB · Views: 34
I used a Wemos and run the RTC in software with battery backed 1307 as main time keeper with it using my wifi to fetch the time (from time server) every 15 mins. Lots of examples on the internet.

Mike.