# DS3231 - No Alarm when powered Off. Why?

**URL:** <https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435>\
**Category:** Programming\
**Created:** [September 10, 2015, 9:35pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435 "2015-09-10T21:35:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![matte00](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@matte00](https://forum.arduino.cc/u/matte00)\
**Post date:** [September 10, 2015, 9:35pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/1 "2015-09-10T21:35:25Z")

</div>

Hi dudes,

this is my first post in Arduino forum so I hope to get it right 🙂

I have a DS3231 RTC with an alarm set. When i disconnect 5V from VCC the alarm don't works. I need an RTC or similar for wake up arduino from sleep. My project need low power because will be powered by battery pack (4xAA ~4.8V).

I need setup an alarm or more (i need 3 wake up daily programmable) that wake up arduino from deep sleep (power save). Example:

08:00 wake up --\> sampling temparature, weight..etc --\> sleep  
14:00 wake up --\> sampling temparature, weight..etc --\> sleep  
19:00 wake up --\> sampling temparature, weight..etc --\> SEND SMS (GSM) --\> sleep again

It's possible? RTC on Arduino not work because during deep sleep is stopped so i need external RTC with very very low consumption.

Can you help me please? Thank you so much...

P.S. I have an Arduino Mini Pro 328P 5V/16Mhz

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [September 10, 2015, 9:41pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/2 "2015-09-10T21:41:04Z")

</div>

None of the RTCs I'm running ever stop when there is no power to the Arduino. You need to tell us a lot more about your hardware configuration, and the circumstances in which this is happening.

But generally you would connect the RTC Int/SQ pin to an arduino interrupt pin, and enable wake from sleep for that pin.

It's also not clear whether you have written software, or whether you are asking how to write it.

---

<div class="post-metadata">

**Author:** ![matte00](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@matte00](https://forum.arduino.cc/u/matte00)\
**Post date:** [September 10, 2015, 10:04pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/3 "2015-09-10T22:04:28Z")

</div>

Hi aarg, thank you for your response!

Sorry, maybe I have not explained well 🙂

I disconnect 5V from RTC's VCC no from arduino. I thought that battery coin on RTC did work also alarms not only keep the correct time. I hope I'm wrong but without 5V VCC on RTC alarm don't works?

I have connected he RTC Int/SQ pin to an arduino interrupt pin but without VCC on RTC it's don't work. If i check V on SQW pin when RTC works with battery it's 0V.

I'm writing software but i need know a method for wake up arduino at specific time but with very low low power consumption.

My hardware configuration is:

- Arduino Mini Pro 328P 5V/16Mz
- MOSFETP IRF9024 + BC547 for low consumption (it's necessary for turn off/on GSM with enough power for connect to GSM network (current peek))
- DHT 22 temperature sensor
- HX771 + Load Cell
- SIM900 GSM
- RTC DS3231 (zs-042)

My dream was power off all and then at specific time (3 times at day) wake up arduino that then power on relative module (dht22, gsm, etc) only when necessary (example GSM only at 3th wakeup will be powered) and then go to deep sleep waiting for next wake up (forced by RTC).

What is the best solution? Thank you 😉

---

<div class="post-metadata">

**Author:** ![marco\_c](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@marco\_c](https://forum.arduino.cc/u/marco_c)\
**Post date:** [September 10, 2015, 10:14pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/4 "2015-09-10T22:14:12Z")

</div>

Have you checked the status of the EOSC bit in the RTC? If this is on, the clock oscillator will stop when power is removed from the clock?

Are the interrupt registers set correctly to enable an interrupt to happen?

Please post your code so we can look at it.

---

<div class="post-metadata">

**Author:** ![guix](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/guix/32/215371_2.png) [@guix](https://forum.arduino.cc/u/guix)\
**Post date:** [September 10, 2015, 10:30pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/5 "2015-09-10T22:30:30Z")

</div>

~~Sadly, the DS3231 does not check alarms when running on battery, only square waves can be enabled to work on battery ( with the BBSQW bit ). So I believe the best you can do with the DS3231 is to wake up your arduino every second (with the 1Hz square wave of course), and turn on the DS3231 so you can check if the alarm flag was set.~~

Sorry I was completely wrong :-[

---

<div class="post-metadata">

**Author:** ![matte00](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@matte00](https://forum.arduino.cc/u/matte00)\
**Post date:** [September 10, 2015, 10:32pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/6 "2015-09-10T22:32:25Z")

</div>

Ciao marco,

I'm using JChristensen library for DS3231

It's the code.

```cpp
#include <LowPower.h>
// RTC - Real Time Clock
#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time  
#include <WSWire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)

// Pin per l'accensione del modulo RTC
int const pinRTC = 11;

void setup()
{
  // Power for RTC from Arduino PIN to RTC VCC
  pinMode(pinRTC, OUTPUT);

  Serial.begin(19200);
  Serial.println("Startup...");
  delay(100);

  // Set Alarm2 every minute
  RTC.setAlarm(ALM2_EVERY_MINUTE, 00, 00, 00, (dowSunday | dowMonday | dowTuesday | dowWednesday | dowThursday | dowFriday | dowSaturday));
  RTC.alarmInterrupt(ALARM_2, true);      //assert the INT pin when Alarm2 occurs.
  delay(100);
}

void wakeUp()
{
  // handling interrupt code
}

void loop()
{
  // Allow wake up pin to trigger interrupt on low.
  attachInterrupt(0, wakeUp, FALLING);
  // Enter power down state with ADC and BOD module disabled.
  // Wake up when wake up pin is low.
  LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

  // Disable external pin interrupt on wake up pin.
  detachInterrupt(0);

  if (RTC.alarm(ALARM_2))
  {
    Serial.println("Alarm fired!");
  }
  else
  {
    Serial.println("-");
  }

  delay (100);

  // Turn on VCC on RTC from out pin arduino
  digitalWrite(pinRTC, HIGH);
  LowPower.powerDown(SLEEP_500MS, ADC_OFF, BOD_OFF); // wait a bit
  // date and time
  tmElements_t tm;
  if (RTC.read(tm) == 0) // Se la lettura è avvenuta correttamente tramite I2C
  {
    Serial.print(tm.Day, DEC);
    Serial.print('/');
    Serial.print(tm.Month, DEC);
    Serial.print('/');
    Serial.print(tm.Year, DEC);
    Serial.print(' ');
    Serial.print(tm.Hour, DEC);
    Serial.print(':');
    Serial.print(tm.Minute, DEC);
    Serial.print(':');
    Serial.println(tm.Second, DEC);
  }
  else
  {
    Serial.println("Errore RTC");
  }
  delay(100);
  // Spengo il modulo RTC
  digitalWrite(pinRTC, LOW);

}

```

---

<div class="post-metadata">

**Author:** ![matte00](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@matte00](https://forum.arduino.cc/u/matte00)\
**Post date:** [September 10, 2015, 10:35pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/7 "2015-09-10T22:35:01Z")

</div>

> guix:  
> Sadly, the DS3231 does not check alarms when running on battery, only square waves can be enabled to work on battery ( with the BBSQW bit ). So I believe the best you can do with the DS3231 is to wake up your arduino every second, and turn on the DS3231 so you can check if the alarm flag was set.

It's really? ☹ D'oh! Have you a solution for my problem, wake up arduino from sleep at specific time of the day? So, alarms don't work in all RTC modules without power?

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [September 10, 2015, 11:23pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/8 "2015-09-10T23:23:01Z")

</div>

You could wake up every second by enabling a 1Hz square wave on \*int/sqw , check the alarms and go back to sleep. The duty cycle would be very low, so not much average power consumption.

---

<div class="post-metadata">

**Author:** ![Paul1958](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@Paul1958](https://forum.arduino.cc/u/Paul1958)\
**Post date:** [September 10, 2015, 11:33pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/9 "2015-09-10T23:33:13Z")

</div>

Is power that much of a concern that you cant leave 5 volts applied to the RTC so that its alarm function works? I bet it is only a few milli Amps.

---

<div class="post-metadata">

**Author:** ![jboyton](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jboyton](https://forum.arduino.cc/u/jboyton)\
**Post date:** [September 10, 2015, 11:48pm UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/10 "2015-09-10T23:48:59Z")

</div>

That's disappointing that it won't generate an interrupt pulse when on battery.

The difference in the current draw between Vcc powered and battery is something like 200:1. It's normal to power these units down in low-power systems.

But having to power the RTC up every second to check the alarm makes the alarm function superfluous for those systems. You might as well just do the check in the uP code. It might make more sense to ignore the RTC time registers and just use the square wave output to generate an interrupt for keeping the time in the uP code.

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [September 11, 2015, 12:04am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/11 "2015-09-11T00:04:18Z")

</div>

> jboyton:  
> That's disappointing that it won't generate an interrupt pulse when on battery.
> 
> The difference in the current draw between Vcc powered and battery is something like 200:1. It's normal to power these units down in low-power systems.
> 
> But having to power the RTC up every second to check the alarm makes the alarm function superfluous for those systems. You might as well just do the check in the uP code. It might make more sense to ignore the RTC time registers and just use the square wave output to generate an interrupt for keeping the time in the uP code.

Not really superfluous, as the alarm test is much faster, just one I2C read to test the flags. In this case, faster means much less power.

---

<div class="post-metadata">

**Author:** ![CrossRoads](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/crossroads/32/214033_2.png) [@CrossRoads](https://forum.arduino.cc/u/CrossRoads)\
**Post date:** [September 11, 2015, 12:22am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/12 "2015-09-11T00:22:30Z")

</div>

Sounds to me that the bits are not getting set correctly in these 2 registers:

Control Register (0Eh)  
Bit 7: Enable Oscillator (EOSC). When set to logic 0,  
the oscillator is started. When set to logic 1, the oscillator  
is stopped when the DS3231 switches to VBAT. This  
bit is clear (logic 0) when power is first applied. When  
the DS3231 is powered by VCC, the oscillator is always  
on regardless of the status of the EOSC bit. When  
EOSC is disabled, all register data is static.

Bit 2: Interrupt Control (INTCN). This bit controls the  
INT/SQW signal. When the INTCN bit is set to logic 0, a  
square wave is output on the INT/SQW pin. When the  
INTCN bit is set to logic 1, then a match between the  
timekeeping registers and either of the alarm registers  
activates the INT/SQW output (if the alarm is also  
enabled). The corresponding alarm flag is always set  
regardless of the state of the INTCN bit. The INTCN bit  
is set to logic 1 when power is first applied.  
Bit 1: Alarm 2 Interrupt Enable (A2IE). When set to  
logic 1, this bit permits the alarm 2 flag (A2F) bit in the  
status register to assert INT/SQW (when INTCN = 1).  
When the A2IE bit is set to logic 0 or INTCN is set to  
logic 0, the A2F bit does not initiate an interrupt signal.  
The A2IE bit is disabled (logic 0) when power is first  
applied.  
Bit 0: Alarm 1 Interrupt Enable (A1IE). When set to  
logic 1, this bit permits the alarm 1 flag (A1F) bit in the  
status register to assert INT/SQW (when INTCN = 1).  
When the A1IE bit is set to logic 0 or INTCN is set to  
logic 0, the A1F bit does not initiate the INT/SQW signal.  
The A1IE bit is disabled (logic 0) when power is  
first applied.

Status Register (0Fh)  
Bit 1: Alarm 2 Flag (A2F). A logic 1 in the alarm 2 flag  
bit indicates that the time matched the alarm 2 registers.  
If the A2IE bit is logic 1 and the INTCN bit is set to  
logic 1, the INT/SQW pin is also asserted. A2F is  
cleared when written to logic 0. This bit can only be  
written to logic 0. Attempting to write to logic 1 leaves  
the value unchanged.  
Bit 0: Alarm 1 Flag (A1F). A logic 1 in the alarm 1 flag  
bit indicates that the time matched the alarm 1 registers.  
If the A1IE bit is logic 1 and the INTCN bit is set to  
logic 1, the INT/SQW pin is also asserted. A1F is  
cleared when written to logic 0. This bit can only be  
written to logic 0. Attempting to write to logic 1 leaves  
the value unchanged.

---

<div class="post-metadata">

**Author:** ![jboyton](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jboyton](https://forum.arduino.cc/u/jboyton)\
**Post date:** [September 11, 2015, 12:24am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/13 "2015-09-11T00:24:27Z")

</div>

CrossRoads, can you find the language in the datasheet that specifically says it works when powered down? I couldn't. Maybe I will test it. I have one wired up on a breadboard at the moment.

---

<div class="post-metadata">

**Author:** ![jboyton](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jboyton](https://forum.arduino.cc/u/jboyton)\
**Post date:** [September 11, 2015, 12:26am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/14 "2015-09-11T00:26:34Z")

</div>

> aarg:  
> Not really superfluous, as the alarm test is much faster, just one I2C read to test the flags. In this case, faster means much less power.

Is it really faster? I haven't written code and done the comparison.

In a low power application the processor is probably also sleeping. Since the RTC apparently doesn't generate interrupts when on battery power, the processor will have to wake up every second just so it can power up the RTC, read a byte and then power it down. Most of the overhead is in the processor waking up. The difference between the power up / I2C read / power down versus comparing two 32-bit variables in RAM isn't the issue.

Or at least that's how I imagine it.

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [September 11, 2015, 12:27am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/15 "2015-09-11T00:27:57Z")

</div>

I'm inclined to believe the bad news, because of the explanation of bit 6 of the control register, BBSQW:

"Bit 6: Battery-Backed Square-Wave Enable  
(BBSQW). When set to logic 1 with INTCN = 0 and VCC  
\< VPF, this bit enables the square wave. When BBSQW  
is logic 0, the INT/SQW pin goes high impedance when  
VCC \< VPF. This bit is disabled (logic 0) when power is  
first applied."

That sounds like an over-ride of INTCN to me.

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [September 11, 2015, 12:31am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/16 "2015-09-11T00:31:17Z")

</div>

> jboyton:  
> Is it really faster? I haven't written code and done the comparison.
> 
> In a low power application the processor is probably also sleeping. Since the RTC apparently doesn't generate interrupts when on battery power, the processor will have to wake up every second just so it can power up the RTC, read a byte and then power it down. Most of the overhead is in the processor waking up. The difference between the power up / I2C read / power down versus comparing two 32-bit variables in RAM isn't the issue.
> 
> Or at least that's how I imagine it.

Well it is your imagination. To do the software compare, the current RTC time must be read and converted from BCD to one of those 32 bit values.

Although, I concede that there might be other benefits to doing it in software. I just though we were talking about power saving here.

---

<div class="post-metadata">

**Author:** ![CrossRoads](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/crossroads/32/214033_2.png) [@CrossRoads](https://forum.arduino.cc/u/CrossRoads)\
**Post date:** [September 11, 2015, 12:34am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/17 "2015-09-11T00:34:49Z")

</div>

I don't see where it says it doesn't work. I see it like this:

0x0E bit 7 must be 0  
0x0E bit 2 must be 1  
0x0E bit 1 or bit 0 must be 1 (alarm 2 or alarm 1 will be signaled)

check the code, see what's really set up.

---

<div class="post-metadata">

**Author:** ![jboyton](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jboyton](https://forum.arduino.cc/u/jboyton)\
**Post date:** [September 11, 2015, 12:38am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/18 "2015-09-11T00:38:43Z")

</div>

> CrossRoads:  
> I don't see where it says it doesn't work.

Me neither. But I also don't see where it says it does work.

I will test it.

---

<div class="post-metadata">

**Author:** ![jboyton](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jboyton](https://forum.arduino.cc/u/jboyton)\
**Post date:** [September 11, 2015, 12:38am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/19 "2015-09-11T00:38:53Z")

</div>

> aarg:  
> Well it is your imagination. To do the software compare, the RTC time must be read and converted from BCD to one of those 32 bit values.

I was imagining keeping time in the processor rather than using the RTC itself. The square wave could feed directly to an interrupt pin on the processor and wake it up every second. Then the processor could keep time internally. Keeping track of time and date is not a complicated algorithm. It could be BCD or any format. Updating time variables takes very few cycles on average.

But you're right, I'm just imagining a system. I don't know what the OP is doing.

---

<div class="post-metadata">

**Author:** ![CrossRoads](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/crossroads/32/214033_2.png) [@CrossRoads](https://forum.arduino.cc/u/CrossRoads)\
**Post date:** [September 11, 2015, 12:41am UTC](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435/20 "2015-09-11T00:41:04Z")

</div>

That says nothing about INTCN = 1 tho. Time for a test I suppose. Who's got a chip?

[Next page](https://forum.arduino.cc/t/ds3231-no-alarm-when-powered-off-why/334435.md?page=2)
