Hi,
I've got a quite simple project and a simple program for it, but I for some reason can't figure it out.
So, I need to make a sketch that turns a relay on every day at the same time for an set ammount of time.
I have a button connected to the Arduino and when I press it should save the current time so it would know when to trigger again next day.
Are there any good timer/alarm libraries that I can use? And, do I need a RTC (Real Time Clock) for this, or would the arduino on its own be good enough?
An RTC would be perfect for this project and would ensure accuracy. The Arduino itself has no way of knowing the actual time unless it is input by the user or derived from another device. The Arduino alone is not very good at timekeeping over a long period, but what degree of accuracy are you looking for ?
Having said that, you do not have a requirement to know the actual time, just how long to leave the relay on and the ability to time 24 hours to do it again.
DzAnej:
Hi,
I've got a quite simple project and a simple program for it, but I for some reason can't figure it out.
So, I need to make a sketch that turns a relay on every day at the same time for an set ammount of time.
I have a button connected to the Arduino and when I press it should save the current time so it would know when to trigger again next day.
Are there any good timer/alarm libraries that I can use? And, do I need a RTC (Real Time Clock) for this, or would the arduino on its own be good enough?
Thanks.
The accuracy of the x-tal on the aruino will propably be +/-10ppm ( These are typical data for a X-tal I have not checked the exact x-tal in the Arduino)
+/- 10 parts per million will give an error of (10/1000000)2460*60[seconds) = 0.86 sec for each day.
kajnorman:
The accuracy of the x-tal on the aruino will propably be +/-10ppm ( These are typical data for a X-tal I have not checked the exact x-tal in the Arduino)
Hardly any Arduino board design is using XTAL for controller clocking nowadays. Those days are gone.
The last official board design for Atmega328, using XTAL, was dhe "ARDUINO DUEMILANOVE" board in year 2009. This is eight years ago.
More modern board designs like "R3" boards are using "ceramic resonators" for creating 16MHz clocking. If modern Arduino boards have XTALs on board, this is for USB clocking only, it's not for microcontroller clocking (except very few boards which use the XTAL for USB and for controller clocking as well).
Ceramic resonators of bad quality may be 0.8% off in timing in worst case, this is 0.8 seconds within 100 seconds. Or one second within two minutes.
One day has 1440 minutes, this might sum up to 720 seconds (12 minutes) of inaccuray when using the internal clocking of a board in "R3 design".
For better accuracy you might want to use a RTC module, which is much more accurate than ceramic resonators.
Or find one of the few boards which is using XTAL for microcontroller clocking until today.
XTALs provide about 80 times more accurate clocking than ceramic resonators. But despite of better accuracy, whith 16 MHz XTAL you will hardly achieve an accuracy of 0.86 sec for each day. Maybe you get 1 sec inaccuracy per 200 minutes with 16MHz XTAL. For higher accuracy use RTC! The low-frequency RTC XTALs are much more accurate than 16 MHz XTALs are. I''d better avoid internal clocking and use RTCmodule instead when using Arduino board programming.