What do people use for a real time clock?

New to Auduino and looking into using it for home automation. It appears Auduino does not have a real time clock that's battery backed up. Wondering what people use? Do you add a battery backed up RTC or use an NTP server to set time when the Auduino powers on?

Are there public sites to obtain sunset/sunrise times which can be used with Auduino?

Thanks

The DS3231 is a good cheap clock.

Nick_Pyner:
The DS3231 is a good cheap clock.

^ 2nd that, i have a bunch of them and using 2 currently in projects

Could one sync the Arduino with an NTP server on the Internet at bootup? And maybe sync once or twice a day? Then there would be no need for the for the clock chip.

Just wondering what the pros and cons would be.

You could do that - assuming that not only is Arduino connected to the Interenet, but also connected to the Interenet when you think it ought to be. Against that, the DS3231 costs about $3 and, at that price, the convenience is pretty hard to pass up.

Genuine Arduino uses the resonator as primary system clock source and it is very inaccurate. I think, to synchronize Arduino once or twice a day would be insufficient on the resolution grade of seconds even the minutes. The DS3231 can be used as secondary clock source for the ATmega chip to drive it via interrupt to obtain an accuracy of seconds very precise.

If you are going to be connecting to the internet anyway (and bandwidth isn't an issue) then using NTP cuts down on your parts count a little. How accurate you need the time to be determines how often you need to re-sync. If you just want to turn the porch light on at sunset then a few minutes either way isnt going to matter. If you are trying to catch the green flash then your timing needs to be somewhat more accurate.

If you type "sunset" into the search bar top right of this page you will find lots of useful discussions about how to compute sunrise and sunset. If you are on the internet there are also services like Sunset and sunrise times API - Sunrise-Sunset.org

I'm just getting started with Arduino and plan on using for home automation. Controlling of lights, (turning on at dusk or push a button which starts a timer to turn them off after x minutes), irrigation and for controlling attic fans, etc.

I'm also would like to install door switches so I can see what doors or gates I may have left open.

I've been trying to find out how to max the number of relays I can control ans switch inputs. Anyone know?

A Mega has 70 pins.

Doug101:
I'm just getting started with Arduino and plan on using for home automation. Controlling of lights, ...

You should use the RTC circuit like DS3231 in such case and NTP could be an addition.

Doug101:
I've been trying to find out how to max the number of relays I can control ans switch inputs. Anyone know?

Many..., say the number. You can use Mega if more IOs are needed or additional I/O circuits - expanders driven via the bus like e.g. PCF8574.