We are making a sensor hub using autonomo , and need to read data every 15minutes or so and sleep rest of the time. Data gathering and sending part is working fine, but we are encountering difficulty when using sleep.
To wake-up, after every ‘X’ time interval we are using RTCZero library
and toggling the onboard LED as a check. The issue is that if
condition is executed once, after that it’s never executed.
The code we used is:
#include <RTCZero.h>
RTCZero rtc;
uint8_t seconds = 0;
uint8_t minutes = 00;
uint8_t hours = 00;
volatile bool rtc_flag = false;
void setup()
{
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(5000);
digitalWrite(13, LOW);
rtc.begin(true);
rtc.setTime(hours, minutes, seconds);
rtc.setAlarmTime(00,1,00);
rtc.enableAlarm(rtc.MATCH_MMSS);
minutes+=1;
rtc.attachInterrupt(alarmMatch);
}
void loop()
{
if(rtc_flag)
{
rtc.disableAlarm();
rtc_flag = false;
digitalWrite(13, HIGH);
delay(1000);
minutes+=1;
rtc.setAlarmTime(00,minutes,00);
rtc.enableAlarm(rtc.MATCH_MMSS);
digitalWrite(13, LOW);
}
rtc.standbyMode(); // Sleep until next alarm match
}
void alarmMatch()
{
rtc_flag = true;
}
}
Is there any other way to achieve sleep of ‘X’ minutes continuously.