Subtitle: is my Arduino narcoleptic?
Hello everyone. After spending 2 days on every single thread about this situation (which is very common as I saw), I have to ask for help.
I got an Arduino Mini Pro (AT168 3V @8MHz) wired with a DS3231 RTC.
My intention was to put arduino in a sleep state (I'm using batteries, so power saving is my main concern) and use a RTC to generate an interrupt on pin #2, wich will wake arduino. Fast, simple, easy.
So I wrote copied some code:
#include <DS3231.h> // DS3231 library provided by mr Jarzebski
#include <LowPower.h>
bool awake= false;
DS3231 clock;
RTCDateTime dt;
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(2, INPUT_PULLUP);
clock.begin();
digitalWrite(8, HIGH); // Test for LED on pin #8
delay(500);
digitalWrite(8, LOW);
dt = clock.getDateTime();
Serial.println(clock.dateFormat("d-m-Y H:i:s - l", dt));
delay(100);
attachInterrupt(0, wakeUp, FALLING); // set interrupt on pin #2
}
void wakeUp(){ // set something
awake = true;
}
void loop()
{
Serial.println("start");
digitalWrite(8, LOW);
clock.setAlarm1(0, 0, 0, 30, DS3231_MATCH_S); // set the alarm on the 30th second of every minute
clock.armAlarm1(true);
Serial.println("zzz...");
delay(100);
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); // Minimum power until the interrupt ring
delay(100); // should be awake here
dt = clock.getDateTime();
Serial.println(clock.dateFormat("d-m-Y H:i:s - l", dt));
Serial.println("ok");
digitalWrite(8, HIGH); // Turn on the lights
delay(2000);
}
Arduino goes to sleep but never wakes up. Using LOW for the interrupt he wakes continuously.
After reading tons of post my guess is: should I use a pullup resistor (even if I defined #2 as INPUT_PULLUP)? Or should I disable some pin/wave gen/thing on the RTC?
Thanks in advance,
Additional info:
- I2C scan says that rtc is reachable on 0x68, as should be.
- The whole thing is (for now) powered by an UNO, which is used also as ISP.
EDIT:
(3v - 1KOmh - LED - SQW)
The led turn on when the alarm ring, so it works.
So the issue is due to pin#2, I'll try to use some resistor.