AUTONOMO+GPRSBEE not waking up again after a few cycles

Hi i am using an Autonomo + GPRS Bee, with RTCZero library i am able to put it to sleep and wake up every 15 mins and post something to thingspeak, but after exactly 4 x 15min successful cycles the Autonomo ceases cycling (and nothing is posted, of course). If i reset it it starts working again … Any ideas? my code is something like this:

> //Alarm & Deep Sleep
> #include <RTCZero.h>
> RTCZero rtc;
> uint8_t seconds = 0;
> uint8_t minutes = 00;
> uint8_t hours = 00;
> volatile bool rtc_flag = false;
> //********************************

> void setup()
> {

>     // Time and alarm setup, start
>     rtc.begin(true);
>     rtc.setTime(hours, minutes, seconds);
>     rtc.setAlarmTime(00,minutes,00);
>     rtc.enableAlarm(rtc.MATCH_MMSS);
>     minutes+=1;
>     rtc.attachInterrupt(alarmMatch);
>     // *************************************

>   
>    while ((!SerialUSB) && (millis() < 10000)); 
>    SerialUSB.begin(115200); // Open serial connection to report values 
>    SerialUSB.println("Starting up");

>    
>   //GPRSBee init 
>   //Start the Bee Serial port initially
>   Serial1.begin(57600);
>   
>   //Switch on the VCC for the Bee socket
>   //digitalWrite(BEE_VCC, HIGH);

>   gprsbee.initAutonomoSIM800(Serial1, BEE_VCC, BEEDTR, BEECTS);
>   gprsbee.setDiag(SerialUSB);

>   //***************************************************


> }


> void loop()
> {

>   {
>         if(rtc_flag)
>   {
>         rtc.disableAlarm();
>         minutes+=15;
>         rtc_flag = false;

>         DO send data to thingspeak

>         rtc.setAlarmTime(00,minutes,00);
>         rtc.enableAlarm(rtc.MATCH_MMSS);
>         
>                
>   }
> rtc.standbyMode(); // Sleep until next alarm match
> }

void alarmMatch()
{
rtc_flag = true;
}

Hi @femuruy

Check your loop function. Minutes variable comes out of range. Every wake-up/sleep cycle you add +15 to minutes. Fifth time “minutes” has a value of 15+15+15+15+15 = 75, so 75 isn’t a value in range 0-59 for minutes.

I suggest you to check if minutes is greater or equal than 60 and if yes, “restart” minutes variables in 0-59 range.

I hope this help you.

Regards.

Hi thanks for your reply … i thought the RTCZero managed time a tad differently and assumed it would just adjust the mins value instead of overflowing … will try to pass this instead …

minutes+=(15 % 60);

dang… didn’t worked … any ideas?

There are a number of things that can be the cause here. Additionally, debugging using the SerialUSB connection is not possible when using sleep mode as entering sleep mode will (abruptly) disable the USB module on the SAMD chip.

Try removing any usage of SerialUSB, both in any debug messages and the debug output from the GPRSbee. It is a good idea to use one of the UARTs. You will need to connect that UART’s output to another device which can send the data to your host machine via USB. Another Arduino compatible board (possibly with a pass through sketch) will work or a USARTbee.

Hi Gabriel, thank you for your reply. The SerialUSB as debug was a legacy from another snippet of code i did, will remove it. I will try passing the minutes differently as "minutes=((minutes + 15) % 60);" because i have no skill to do further debugging i think … by the way what is the correct serial speed to put for the GPRSBee @serial1.begin?

Regards!

that did the trick :smile: