How to adapt my latch circuit to work with RTC DS3231

(deleted)

(deleted)

Yes, but your circuit seems pretty complicated to me. I'll attach something simpler.

By the way, the INT output goes high only when you clear the alarm flag. Setting a new alarm is a separate action. However, libraries may combine the two, which is not always helpful.

In the attached circuit, the Arduino turns on the power to the DS3231, sets the new alarm time, then as a final act clears the alarm, which turns off the power. The DS3231 then operates off the coin cell, but the INT alarm will still work. When the alarm triggers, you just leave it low until you're ready to turn off the power.

This arrangement requires that the pullup resistor on the DS3231 module be disconnected (you cut the trace), and the Arduino interrupt pin be set to INPUT_PULLUP.

But yes, as you discovered, the INT should drive the gate of a P-channel mosfet.

(deleted)

I'm not sure which battery you're asking about. There is the main battery for the project, an 18650 in my example, and then there is the CR2032 coin cell on the back of the DS3231 module. When external power (at the Vcc pin) is removed from the module for any reason, the coin battery automatically takes over and keeps the time clock going. So if you remove the main battery to recharge it, you would still have the correct time when you replace the battery.

(deleted)

Yes, that pin is an open drain output. It can't bring the line high because the upper transistor normally present on a regular GPIO output just isn't there. But when the alarm is triggered, the lower transistor is turned on, which gounds the pin. So it's either Off or Low, but it's the pullup resistor that makes the pin High if the transistor is off. The pin stays low until you clear the alarm by writing to the appropriate register.

(deleted)