I'm using the SparkFun DeadOn RTC Breakout in my project and I want it to generate an interrupt that wakes my Arduino Pro Mini at 6am each day. I can get my project to work with a manually generated interrupt, but get nothing from the RTC. The SQW pin stays low all the time, even though it is tied to Vcc with a 10k resistor.
Here's the relevant part of my code. Am I doing (or not doing) something silly, or could it be a defective breakout?
#include <SPI.h>
#include <SparkFunDS3234RTC.h>
#define DS13074_CS_PIN 10 // RTC CS is pin 10
#define INTERRUPT_PIN 3 // RTC SQW/interrupt pin
void wake ()
{
// cancel sleep as a precaution
sleep_disable();
// precautionary while we do other stuff
detachInterrupt (1);
}
void setup()
{
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
rtc.begin(DS13074_CS_PIN); // Initialize RTC
rtc.enableAlarmInterrupt();
rtc.setAlarm1(0, 00, 06); // Alarm 1: 0600hrs
}
void loop()
{
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
sleep_enable();
// Do not interrupt before we go to sleep, or the
// ISR will detach interrupts and we won't wake.
noInterrupts ();
// will be called when pin D3 goes low
attachInterrupt (1, wake, FALLING);
EIFR = bit (INTF1); // clear flag for interrupt 1
// We are guaranteed that the sleep_cpu call will be done
// as the processor executes the next instruction after
// interrupts are turned on.
interrupts(); // one cycle
sleep_cpu(); // one cycle
//Insert code to run when Arduino wakes on interrupt
}
Thanks,
Mike
solderingiron:
The SQW pin stays low all the time, even though it is tied to Vcc with a 10k resistor.
I don't see the code do that so the million dollar question, what is the config of the DS3234?
In your program, you are missing
rtc.setTime(<second>, <minute>, <hour>, <day>, <date>, <month>, <year>)
How would the RTC know what time it is?
septillion:
I don't see the code do that so the million dollar question, what is the config of the DS3234?
add a conditional print statement to your sketch to know if it's the DS3234 pulling it low or something else in your circuit.
if (rtc.alarm1()) Serial.println("ALARM 1 is triggered!");
Thanks for your replies. To clarify the points raised:
I based the RTC configuration on the SparkFun tutorial so I don't think I'm missing any setup statements.
Mike
solderingiron:
I based the RTC configuration on the SparkFun tutorial so I don't think I'm missing any setup statements.
Mike
I based my responses on this tutorial. To quote it
Finally, to use the SQW pin as an interrupt, call the rtc.enableAlarmInterrupt(); function. The interrupt is active-low, which means you’ll want to pull the pin high through a resistor (or an internal pull-up). When the pin reads low, an interrupt has occurred, which means its time to read either/both of the alarm() functions.
So, if it is low all the time, it is in alarm all the time. Perhaps you want to look at this example and add a bit more of it to your code.
Perehama:
I based my responses on this tutorial. To quote itSo, if it is low all the time, it is in alarm all the time. Perhaps you want to look at this example and add a bit more of it to your code.
Thanks. I will let you know if that helps!
Mike
septillion:
- Show the sketch which set the config. My crystal ball is broken so I have no clue.
- Why not at least add a statment to print the current time once in a while

I used the rtc.autoTime() function in the DS_3234_RTC sketch to set up the clock and I know the clock's working because I have been using it to log temperature sensors for several days now.
Anyway I have just got this wretched interrupt to work by adding a 100ms delay at the end of void setup(), but I have absolutely no idea why!
Mike