Skip to main content
2 of 2
added 7 characters in body
ocrdu
  • 1.8k
  • 3
  • 12
  • 24

Programming Arduino Uno R3 to trigger a relay once every 24 hours

I programmed an Arduino Uno R3 to trigger a relay once every 24 hours from the moment it is powered on.

I calculated milliseconds and used the function delay().

24 hours * 60 minutes each hour * 60 second every minute * 1000 milliseconds every second

so I used :

delay(86400000)

for 86 million and 400 thousands milliseconds.

Currently, I'm still testing it...

Will this work? If not, is there a better built-in function/library or even external library to do it?

The relay trigger doesn't have to be very accurate at the very exact time each day.

I don't need it to be very accurate, it can shift few minutes every few months or so, thats okay with me.

But how about after few months or years of use ? Will it shift the timing much?

I read somewhere about using millis() function and others use an RTC (Real Time Clock) module.

I don't want to use anRTC module, I am looking for a programmatical solution.

OR will my previous method using delay() work for such a very high number of milliseconds?