I am building a night light that will turn on when it detects motion using a Passive Infrared (PIR) sensor. I only want the light to turn on overnight, between specific hours that I specify. Outside of this time the Arduino will sleep.
For my Arduino to check the time, there are a couple of options:
1. Real-time clock
Description: A small add-on board powered by a cell battery (lifetime usually a couple of years). The user sets the time manually after the battery is inserted. Communicates with the microcontroller via SPI, I2C, etc. Upon request from the microcontroller (using a supplied real-time clock library function), the real-time clock sends back the current time (in a specified format).
- Completely offline
- The clock time can drift (due to electronic component manufacturing tolerances, temperature cycles and oscillator ageing).
To account for daylight saving, a "daylight saving" switch could be used that is manually set by the user.
2. WiFi link to an Internet time server
Description: A WiFi add-on board that allows access to the Internet. A time server could be requested for a specific time.
- Daylight saving is taken into account automatically
- Clock would not need resyncing periodically
- Dependent on connection to the Internet
- Dependent on availability of time server
- Before I invest hours of time into making something work, are there any other options?
- How much could a real-time clock be expected to drift after a year? (I'd be happy with +/- 15 minutes).
- Are there any pitfalls with trying to obtain the time from an Internet time server?
I guess a third option is a combination: an Internet time-syncing Real-Time Clock that conducts synchronisation every week or so!
Note: I am planning on using my Arduino Pro Mini, but I wouldn't be against investing in other hardware.