Help with DS3231 interrupt.

Im trying to get interrupt signal every second and I want to see it on oscilloscope but im out of luck.
Square wave output works fine on INT/SQW pin.

Here is a messy code:
First one is to set the alarm:

#include <Wire.h>
void setup() {
  Wire.begin();

}

void loop() {
  /*
  Wire.beginTransmission(104);        //A1M1 =1
  Wire.write(0x07);
  Wire.write(B10000000);
  Wire.endTransmission();

  Wire.beginTransmission(104);        //A1M2 =1
  Wire.write(0x08);
  Wire.write(B10000000);
  Wire.endTransmission();

  Wire.beginTransmission(104);        //A1M3 =1
  Wire.write(0x09);
  Wire.write(B10000000);
  Wire.endTransmission();
*/
  Wire.beginTransmission(104);        //A1M4 =1
  Wire.write(0x0A);
  Wire.write(B10000000);
  Wire.endTransmission();

  Wire.beginTransmission(104);        //Turn on alarm1 A1IE and set INTCN to 1
  Wire.write(0x0E);
  Wire.write(B00000101);
  Wire.endTransmission();

  //SET ALARM//
  Wire.beginTransmission(104);        //Secs to 10
  Wire.write(0x07);
  Wire.write(B10010000);
  Wire.endTransmission();
  
  Wire.beginTransmission(104);        //Minutes to 40
  Wire.write(0x08);
  Wire.write(B11000000);
  Wire.endTransmission();

  Wire.beginTransmission(104);        //Hours to 19
  Wire.write(0x09);
  Wire.write(B10011001);
  Wire.endTransmission();
  while(0);
}

The other one is to read most of the register data from the DS3231:

#include "Wire.h"
byte MaskLowNibble = B00001111 ;                      
byte MaskSix = B00111111;                             
byte MaskBit7 = B01111111;                           
byte MaskBit6 = B01000000;
byte MaskBit5 = B00100000;
byte MaskBit5and4 = B00110000;
byte ReceivedSeconds ;
byte Seconds ;
byte Seconds10 ;
byte ReceivedMinutes;
byte Minutes ;
byte Minutes10 ;
byte ReceivedHours;
byte Hours;
byte Hours20;
byte Day;
byte ReceivedDate;
byte Date10;
byte Date;
byte ReceivedMonth;
byte Month;
byte Month10;
byte ReceivedYear;
byte Year;
byte Year10;
//ALARMS
byte A1M1;
byte ReceivedAlarm1Seconds;
byte Seconds10Alarm1;
byte SecondsAlarm1;
byte A1M2;
byte ReceivedAlarm1Minutes;
byte Minutes10Alarm1;
byte MinutesAlarm1;
byte A1M3;
byte ReceivedAlarm1Hours;
byte Hours20Alarm1;
byte HoursAlarm1;
byte twelveTwentyFour;
byte AmPm20HourAlarm1;
byte A1M4;
byte DayAlarm1;
byte DayDateAlarm1;
byte Date10Alarm1;
byte ReceivedDateAlarm1;
byte DyDtAlarm1;
//****CONTROL REGISTER****//
byte Control;
//****SETUP****
void setup() {
  Wire.begin();
  Serial.begin(9600);

}
//****START PROGRAM****
void loop() {
  //****SECONDS****
  Wire.beginTransmission(104);
  Wire.write(0x0);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedSeconds = Wire.read();
  //secs = (secs / 16 * 10) + (secs % 16);
  //****seconds bcd to dec math****
  Seconds10 = ReceivedSeconds >> 4 ;
  Seconds = ReceivedSeconds & MaskLowNibble ;
  //****MINUTES****
  Wire.beginTransmission(104);
  Wire.write(0x01);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedMinutes = Wire.read();
  //****minutes bcd to dec math****
  Minutes10 = ReceivedMinutes >> 4;
  Minutes = ReceivedMinutes & MaskLowNibble ;
  //****HOURS****
  Wire.beginTransmission(104);
  Wire.write(0x02);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedHours = Wire.read();
  //****hours bcd to dec math****
  Hours20 = ReceivedHours & MaskSix;
  Hours20 = Hours20 >> 4;
  Hours = ReceivedHours & MaskLowNibble;
  //****DAY****
  Wire.beginTransmission(104);
  Wire.write(0x03);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  Day = Wire.read();
  //****DATE****
  Wire.beginTransmission(104);
  Wire.write(0x04);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedDate = Wire.read();
  Date10 = ReceivedDate >> 4;
  Date = ReceivedDate & MaskLowNibble;
  //****MONTH****
  Wire.beginTransmission(104);
  Wire.write(0x05);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedMonth = Wire.read();
  Month = ReceivedMonth & MaskLowNibble;
  Month10 = ReceivedMonth & MaskSix;
  Month10 = Month10 >> 4;
  //****YEAR****
  Wire.beginTransmission(104);
  Wire.write(0x06);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedYear = Wire.read();
  Year =  ReceivedYear & MaskLowNibble;
  Year10 = ReceivedYear >> 4;
  //****ALARM1****
  Wire.beginTransmission(104);
  Wire.write(0x07);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedAlarm1Seconds = Wire.read();
  A1M1 = ReceivedAlarm1Seconds >> 7;
  SecondsAlarm1 = ReceivedAlarm1Seconds & MaskLowNibble;
  Seconds10Alarm1 = ReceivedAlarm1Seconds & MaskBit7;
  Seconds10Alarm1 = Seconds10Alarm1 >> 4;
  Wire.beginTransmission(104);
  Wire.write(0x08);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedAlarm1Minutes = Wire.read();
  A1M2 = ReceivedAlarm1Minutes >> 7;
  Minutes10Alarm1 = ReceivedAlarm1Minutes & MaskBit7;
  Minutes10Alarm1 = Minutes10Alarm1 >> 4;
  MinutesAlarm1 = ReceivedAlarm1Minutes & MaskLowNibble;
  Wire.beginTransmission(104);
  Wire.write(0x09);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedAlarm1Hours = Wire.read();
  HoursAlarm1 = ReceivedAlarm1Hours & MaskLowNibble;
  A1M3 = ReceivedAlarm1Hours >> 7;
  twelveTwentyFour = ReceivedAlarm1Hours & MaskBit6;
  twelveTwentyFour = twelveTwentyFour >> 6;
  AmPm20HourAlarm1 = ReceivedAlarm1Hours & MaskBit5;
  AmPm20HourAlarm1 = AmPm20HourAlarm1 >> 5 ;
  Hours20Alarm1 = ReceivedAlarm1Hours & MaskBit5and4;
  Hours20Alarm1 = Hours20Alarm1 >> 4;
  //HoursAlarm1 = ReceivedAlarm1Hours & MaskLowNibble;
  Wire.beginTransmission(104);
  Wire.write(0x0A);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  ReceivedDateAlarm1 = Wire.read();
  A1M4 = ReceivedDateAlarm1 >> 7;
  DyDtAlarm1 = ReceivedDateAlarm1 & MaskBit6;
  DyDtAlarm1 = DyDtAlarm1 >> 6;
  Date10Alarm1 = ReceivedDateAlarm1 & MaskBit5and4;
  Date10Alarm1 = Date10Alarm1 >> 4;
  DayDateAlarm1 = ReceivedDateAlarm1 & MaskLowNibble;
  //****CONTROL REGISTER****//
  Wire.beginTransmission(104);
  Wire.write(0x0E);
  Wire.endTransmission();
  Wire.requestFrom(104, 1);
  Control = Wire.read();

  //****PRINT DATA****
  Serial.println("***************************************");
  Serial.print(Date10);
  Serial.print(Date);
  Serial.print(".");
  Serial.print(Month10);
  Serial.print(Month);
  Serial.print(".");
  Serial.print(Year10);
  Serial.print(Year);
  Serial.print(" ");
  Serial.print(Hours20);
  Serial.print(Hours);
  Serial.print(":");
  Serial.print(Minutes10);
  Serial.print(Minutes);
  Serial.print(":");
  Serial.print(Seconds10);
  Serial.print(Seconds);
  Serial.print(" Day in the week is ");
  Serial.println(Day);
  Serial.print("A1M1=");
  Serial.print(A1M1);
  Serial.print(" Alarm1 seconds=");
  Serial.print(Seconds10Alarm1);
  Serial.println(SecondsAlarm1);
  Serial.print("A1M2=");
  Serial.print(A1M2);
  Serial.print(" Alarm Minutes=");
  Serial.print(Minutes10Alarm1);
  Serial.println(MinutesAlarm1);
  Serial.print("A1M3=");
  Serial.print(A1M3);
  Serial.print(" twelve(1) twneyfour(0)=");
  Serial.print(twelveTwentyFour);
  Serial.print(" If 12 Hour Mode than Am(0) Pm(1)=");
  Serial.print(AmPm20HourAlarm1);
  Serial.print(" Hours=");
  Serial.print(Hours20Alarm1);
  Serial.println(HoursAlarm1);
  Serial.print("A1M4=");
  Serial.print(A1M4);
  Serial.print(" Day(1) Date(0)=");
  Serial.print(DyDtAlarm1);
  Serial.print(" Date or Day=");
  Serial.print(Date10Alarm1);
  Serial.println(DayDateAlarm1);
  Serial.print("Control register=");
  Serial.println(Control,BIN);
  delay(1000);
}

Any advice on how to get the interrupt going?

Thanks.

Im trying to get interrupt signal every second and I want to see it on oscilloscope but im out of luck.
Square wave output works fine on INT/SQW pin.
Any advice on how to get the interrupt going?

I'm pretty sure the interrupt is going, and is driving the INT/SQW pin low. You need to clear the A1F alarm flag to re-enable the interrupt.

When you set the four alarm1 registers for the alarm every second, you don't need to set any of the other alarm registers. Why are you setting alarm time registers for 19:40:10?

The INT/SQW output is open collector (or drain), which means you have to have a pullup resistor to Vcc to see the output.

Beware that some DS3231 modules have pullup resistors to the module Vcc. If the module is not being powered, with the chip running off the battery, those pullups effectively short circuit the INT/SQW output.

See this blog on various modifications to those modules.

cattledog:
When you set the four alarm1 registers for the alarm every second, you don't need to set any of the other alarm registers. Why are you setting alarm time registers for 19:40:10?

I tought that if I set alarm time interrupt will come alive.
I will try to clear the interrupt flag and see what happens.
Thanks.

jremington:
The INT/SQW output is open collector (or drain), which means you have to have a pullup resistor to Vcc to see the output.

Beware that some DS3231 modules have pullup resistors to the module Vcc. If the module is not being powered, with the chip running off the battery, those pullups effectively short circuit the INT/SQW output.

See this blog on various modifications to those modules.

I have a chinese module from the ebay, its called DS3231 AT24C32 IIC , it has pullups on the SDA and SCL, it probbly has one on INT/SQW, I will check it out.
Thanks.