๐ŸŒ
DroneBot Workshop
dronebotworkshop.com โ€บ real-time-clock-arduino
Using a Real Time Clock with Arduino | DroneBot Workshop
April 12, 2023 - The constant DS1307_CTRL_ID defines the I2C address of the real time clock chip. The function setSQW is really where the โ€œactionโ€ is. This function writes to the control register in the DS1307 and sets the square wave frequency to 1Hz. The handleInt function is the interrupt handler. Every time a pulse is received on the D2 pin it will be called. This is set up in the Setup function using the Arduino attachInterrupt function.
๐ŸŒ
Arduino Forum
forum.arduino.cc โ€บ projects โ€บ programming
Triggering Interrupts with Real Time Clock - Programming - Arduino Forum
April 2, 2012 - The overall goal is to put the processor to sleep and then wake it after an hour or so. I looked at using a watchdog timer, but it only goes up to 8 seconds and is reportedly unreliable.
Discussions

Recording real-time data collection with interrupt on Arduino - Stack Overflow
I've been working on collecting flow rates using the Arduino interrupt and I want to time stamp the data using a real-time clock. I have both sketches working individually using the Arduino example... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Using an external clock and the interrupt function
I have bought a DS3234 real-time clock because apparently they are programmable. First of all I was wondering if anyone knew how you would go about programming it to emit a signal once every minute. Assuming it emits a signal every minute: How can I put the Arduino into sleep mode whilst it ... More on forum.arduino.cc
๐ŸŒ forum.arduino.cc
0
0
July 8, 2016
How to set up one second interrupt/ISR for ds3231 RTC - Arduino Stack Exchange
I am able to set up one hz interrupts using millis and other timers, but would like to do it instead using the RTC I have attached (DS3231) I am not sure how I can do that. Can someone point me t... More on arduino.stackexchange.com
๐ŸŒ arduino.stackexchange.com
Arduino Real Time Clock - Using the Tiny RTC
Today we will add a Real-Time Clock to an Arduino. Iโ€™ll show you how the Tiny RTC is hooked up and how to use two ways, including with interrupts. We ... More on forum.dronebotworkshop.com
๐ŸŒ forum.dronebotworkshop.com
11
January 16, 2021
๐ŸŒ
Random Nerd Tutorials
randomnerdtutorials.com โ€บ home โ€บ arduino โ€บ arduino ide โ€บ arduino with ds3231 real time clock (rtc): getting time and setting alarms
Arduino DS3231 Real Time Clock (RTC): Time and Alarms | Random Nerd Tutorials
April 28, 2025 - When an interrupt is triggered, weโ€™ll toggle the state of an LED connected to Pin 3 (so, to test this example, add an LED to your circuit by connecting it to Pin 3). /********* Rui Santos & Sara Santos - Random Nerd Tutorials Complete instructions at https://RandomNerdTutorials.com/arduino-ds3231-real-time-clock/ *********/ // Example based on the library: implementation of an alarm using DS3231 #include <RTClib.h> RTC_DS3231 rtc; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; // the pin that is connected to SQW #define CLOCK_INTER
๐ŸŒ
GitHub
github.com โ€บ IowaDave โ€บ RTC-DS3231-Arduino-Interrupt
GitHub - IowaDave/RTC-DS3231-Arduino-Interrupt: Tricks I learned about using a DS3231 Real Time Clock to interrupt an Arduino ยท GitHub
Enable the Arduino's main loop to ignore the clock while it performs other tasks. When the alarm happens, the DS3231 will pull the Arduino pin "low", that is, to near-zero voltage.
Author ย  IowaDave
๐ŸŒ
Circuit Basics
circuitbasics.com โ€บ how-to-use-a-real-time-clock-module-with-the-arduino
How to Use a Real-time Clock Module with the Arduino
October 21, 2024 - The frequency of the square-wave can be changed between 1Hz, 4kHz, 8kHz, or 32kHz programmatically. this pin can also be used programmed as an interrupt output. ... The SCL, SDA, VCC, and GND pins at the right side of the module are connected ...
๐ŸŒ
PCB HERO
pcb-hero.com โ€บ blogs โ€บ lickys-column โ€บ how-to-use-a-real-time-clock-module-with-the-arduino
How to use a real-time clock module with the arduino? โ€“ PCB HERO
The frequency of the square-wave can be changed between 1Hz, 4kHz, 8kHz, or 32kHz programmatically. this pin can also be used programmed as an interrupt output. ... The SCL, SDA, VCC, and GND pins at the right side of the module are connected ...
๐ŸŒ
Notes
henryleach.com โ€บ 2022 โ€บ 03 โ€บ arduino-real-time-clock
Arduino & Real-Time Clock | Notes - Henry Leach
You can enter the time live into the Arduino IDE's serial console, and if the RTC doesn't loose power (this is where the back-up button battery is useful), it'll remember the time until the next time you want to use it. Another great feature of the DS3231 is that it features two built in alarms, either of which can trigger the square wave pin. If this is connected to an Arduino pin that is waiting for an interrupt, it can be used to, well, interrupt the Arduino from its current activity and respond to the alarm.
๐ŸŒ
Arduino
docs.arduino.cc โ€บ tutorials โ€บ uno-r4-wifi โ€บ rtc
Arduino UNO R4 WiFi Real-Time Clock | Arduino Documentation
March 16, 2026 - 8 RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE); ... A periodic interrupt allows you to set a recurring callback.
Find elsewhere
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 65308228 โ€บ recording-real-time-data-collection-with-interrupt-on-arduino
Recording real-time data collection with interrupt on Arduino - Stack Overflow
#include "RTClib.h" RTC_DS1307 rtc; int Pulses =2; //Digital Pin 2 on Uno volatile int pulsecount; //Volatile integer to store pulse count in void setup() { Serial.begin(9600); rtc.begin(); //start rtc pinMode(Pulses, INPUT); //Make Pin2 Input attachInterrupt(digitalPinToInterrupt(Pulses), CountPulses ,FALLING); //Use interrupt on "Pulses" Pin, count on the falling edge, store in CountPulses } //create a function that adds up the pulsecount void CountPulses() { pulsecount++; } void loop() { DateTime time = rtc.now(); //Get the time from RTC Serial.print(String("DateTime::TIMESTAMP_TIME:\t") +
๐ŸŒ
Little Bird Electronics
learn.littlebirdelectronics.com.au โ€บ guides โ€บ real-time-clock-with-arduino
Real-time clock with Arduino | Little Bird Guides
The Arduino is not able to tell whether it is a 'Thursday' or a 'Friday', either. For those purposes, a real-time clock module can be used instead. In this guide, learn to connect a DS1307 Real Time Clock (RTC) Module with the Little Bird - Uno R3 and program it for time-keeping. Then, learn to use the RTC module and interrupts to put the Uno R3 in and out of power-saving mode.
๐ŸŒ
Simple Circuit
simple-circuit.com โ€บ home โ€บ arduino real time clock with alarm and temperature monitor
Arduino Real Time Clock with Alarm and Temperature Monitor
/* Arduino real time clock and calendar with 2 alarm functions and temperature monitor using DS3231 Read DS3231 RTC datasheet to understand the code Time & date parameters can be set using two push buttons connected to pins 9 (B1) & 10 (B2).
Published ย  April 10, 2024
๐ŸŒ
Arduino
docs.arduino.cc โ€บ tutorials โ€บ uno-r4-minima โ€บ rtc
Arduino UNO R4 Minima Real-Time Clock | Arduino Documentation
8 RTCTime startTime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE); ... A periodic interrupt allows you to set a recurring callback.
๐ŸŒ
Fabricegillotte
dev-124.fabricegillotte.com โ€บ free-beat โ€บ arduino-real-time-clock-code-and-guide-1767647644
Arduino Real Time Clock: Code & Guide
January 6, 2026 - Search online for a wiring diagram specific to your RTC module (DS3231 or DS1307) and Arduino Uno. There are tons of great diagrams available that can help you visualize the connections. ... Some RTC modules may have additional pins, such as an interrupt pin (INT) or a square wave output pin (SQW). These pins are optional and arenโ€™t required for basic timekeeping functionality.
๐ŸŒ
Arduino Forum
forum.arduino.cc โ€บ projects โ€บ programming
Using an external clock and the interrupt function - Programming - Arduino Forum
July 8, 2016 - I have bought a DS3234 real-time clock because apparently they are programmable. First of all I was wondering if anyone knew how you would go about programming it to emit a signal once every minute. Assuming it emits a signal every minute: How can I put the Arduino into sleep mode whilst it ...
Top answer
1 of 4
4

This answer addresses the original question of why the interrupts didn't work. I happened to have a DS3231 lying around so I made up a test.


Interrupt vs pin number

First, this is wrong in your code:

attachInterrupt(rtcTimerIntPin, rtc_interrupt, RISING);

You need an interrupt number, not a pin number. This is correct:

  attachInterrupt (digitalPinToInterrupt (rtcTimerIntPin), rtc_interrupt, CHANGE);

I also made it a CHANGE interrupt so you get both the rising and falling pulse.


Pull-up resistor

Next, the 1 Hz output needs a pull-up resistor, so you should add that or make it INPUT_PULLUP like this:

  pinMode (rtcTimerIntPin, INPUT_PULLUP);

Testing

I used this library from Adafruit.

Adapting one of their examples, and putting in your interrupt code (with my modifications), it worked!

#include <Wire.h>
#include "RTClib.h"

RTC_DS3231 rtc;

const byte rtcTimerIntPin = 2;

volatile byte flag = false;

void rtc_interrupt ()
{
  flag = true;
}  // end of rtc_interrupt

void setup () {

  Serial.begin(115200);

  while (!Serial); // for Leonardo/Micro/Zero

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }

  // enable the 1 Hz output
  rtc.writeSqwPinMode (DS3231_SquareWave1Hz);

  // set up to handle interrupt from 1 Hz pin
  pinMode (LED_BUILTIN, OUTPUT);
  pinMode (rtcTimerIntPin, INPUT_PULLUP);
  attachInterrupt (digitalPinToInterrupt (rtcTimerIntPin), rtc_interrupt, CHANGE);
}

void loop () {
  if (flag) {
    digitalWrite(LED_BUILTIN, HIGH);    // flash the led
    delay(100);                         // wait a little bit
    digitalWrite(LED_BUILTIN, LOW);     // turn off led
    flag =  false;                      // clear the flag until timer sets it again
  }
}
2 of 4
1

Use this DS3231 library. It has a method to set the squarewave RTC.squareWave(SQWAVE_1_HZ)

๐ŸŒ
Dev-eth0
dev-eth0.de โ€บ 2017 โ€บ 09 โ€บ 18 โ€บ arduino-ds3231-alarm
dev-eth0.de - Use a DS3231 RTC to wakeup an Arduino
September 18, 2017 - I bought a DS32313 which is a real low-cost alternative (~6 Euro including a coin battery). The RTC requires either 3.3V or 5V and uses I2C to communicate with the Arduino. The SQW pin needs to be attached to one of the interrupt pins of your Arduino (e.g. for a Nano itโ€™s D2 or D3). You can find a sketch I uploaded to github which shows, how to set the clock and configure an alarm which then wakes up the Arduino4.
๐ŸŒ
Arduino Getting Started
arduinogetstarted.com โ€บ tutorials โ€บ arduino-rtc
Arduino - RTC | Arduino Getting Started
1 week ago - To get date and time, we needs to use a Real-Time Clock (RTC) module such as DS3231, DS1370. DS3231 Module has higher precision than DS1370. See DS3231 vs DS1307 ... SQW pin: outputs a nice square wave at either 1Hz, 4kHz, 8kHz or 32kHz and can be handled programmatically. This can further be used as an interrupt due to alarm condition in many time-based applications.
๐ŸŒ
Arduino
projecthub.arduino.cc โ€บ paulsb โ€บ accurate-clock-just-using-an-arduino-cd5ec8
Accurate Clock Just Using an Arduino | Arduino Project Hub
" 67 }; 68 69void setup() { 70 // Set up time interrupt - millis() rolls over after 50 days so 71 // we are using our own millisecond counter which we can reset at 72 // the end of each day 73 TCCR0A = (1 << WGM01); //Set the CTC mode Compare time and trigger interrupt 74 OCR0A = 0xF9; //Set value for time to compare to ORC0A for 1ms = 249 (8 bits so max is 256) 75 //[(Clock speed/Prescaler value)*Time in seconds] - 1 76 //[(16,000,000/64) * .001] - 1 = 249 = 1 millisecond 77 TIMSK0 |= (1 << OCIE0A); //set timer compare interrupt 78 TCCR0B |= (1 << CS01); //Set the prescale 1/64 clock 79 TCCR0
๐ŸŒ
DroneBot Workshop
forum.dronebotworkshop.com โ€บ forums โ€บ dronebot workshop v... โ€บ 2019 videos
Arduino Real Time Clock โ€“ Using the Tiny RTC
January 16, 2021 - The Tiny RTC is based upon the DS1307 real-time clock chip. This chip provides readings of the second, minute, hour, day, day of the week, month, and year. It adjusts for leap years and has a battery backup. And its available from several sources and it is very inexpensive. Iโ€™ll show you how to hook up the Tiny RTC and how to set and read the time. We will then look at a more advanced method of using the Tiny RTC, using interrupts.