Interrogating DS1307 RTC module to get hourly writes to data file

I use the DS1307 RTC module which is part of the data logger shield for an Arduino Uno. Every hour I write data to the SD card with a temperature reading date and time stamped. This hourly write is accomplished by using the Uno timer but surely there must be a better way of doing this.

Can I detect when the DS1307 increments by an hour but I'm unsure how this can be done. Another way would be to use the square wave output set to 1Hz from the DS1307 and count to 3600?

Any suggestions which is the best method - thanks?


Check the hour and note the change

  if (h != hour)
   h = hour;

I imagine counting seconds to 3600 would work but rather pointless when you already have a clock in your hand that will actually tell what the hour is. If you don't care what the hour is, you don't need the RTC, and millis would do just as well.

Counting the pulses of a 1 Hz signal will work quite well. If you want to save power, let the Arduino sleep and T2 count the pulses. This 8 bit timer will overflow several times in an hour and wake up the controller, so that you have to track how often the counter overflows.

Thanks spycatcher2k, Nick_Pyner and DrDiettrich for your helpful suggestions.

I tried the Nick_Pyner code and it worked well - much better than my existing method. The possibility of using my 1Hz counting method to enable a sleep power saver as suggested by DrDiettrich may well be another good option.

Such a great forum with so many helpful contributors.