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


  1. Before I invest hours of time into making something work, are there any other options?
  2. How much could a real-time clock be expected to drift after a year? (I'd be happy with +/- 15 minutes).
  3. 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.

  • 1
    A DS3231 RTC is quite accurate. Check this page for its test result on time drift. switchdoc.com/2014/12/… – Dat Ha Oct 28 '16 at 12:10
  • 1
    Other options: GPS receiver (should get rough time even with only 1 satellite in view), radio time signal (DCF77, WWVB, etc., depending on your location) or maybe even forget completely about time and use an LDR to know when it's dark enough for the light to be useful. BTW, the DS3231 is good to ±2 ppm, i.e. 63.1 seconds per year. – Edgar Bonet Oct 28 '16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.