Hi gabriel,
Thank u for ur help but unfortunately your code didn’t work well for me. Maybe you’re using a different library or working on the sodaq one instead of the sodaq autonomo.
Here’s a sketch that worked (power consumption ~ 80 uA):
#include <Sodaq_RN2483.h>
#include <Sodaq_RN2483_internal.h>
#include <Sodaq_wdt.h>
#include <Utils.h>
/*
Sleep RTC Alarm for Arduino Zero
Demonstrates the use an alarm to wake up an Arduino zero from Standby mode
This example code is in the public domain
http://arduino.cc/en/Tutorial/SleepRTCAlarm
created by Arturo Guadalupi
17 Nov 2015
modified
01 Mar 2016
NOTE:
If you use this sketch with a MKR1000 you will see no output on the serial monitor.
This happens because the USB clock is stopped so it the USB connection is stopped too.
To see again the USB port you have to double tap on the reset button!
*/
#include <RTCZero.h>
#define loraSerial Serial1
#define beePin BEE_VCC
#define debugSerial SerialUSB
#define sleepTime 120000
/* Create an rtc object */
RTCZero rtc;
/* Change these values to set the current initial time */
uint8_t seconds = 0;
uint8_t minutes = 00;
uint8_t hours = 00;
volatile bool rtc_flag = false;
/* Change these values to set the current initial date */
/const byte day = 17;
const byte month = 11;
const byte year = 15;/
void setup()
{
String str;
debugSerial.begin(57600);
//delay(20000);
//debugSerial.println(“Starting”);
loraSerial.begin(LoRaBee.getDefaultBaudRate());
digitalWrite(beePin, HIGH);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
/bool a;
a=LoRaBee.sendCommand("sys sleep ", "20000 ");
debugSerial.println(a);/
rtc.begin();
rtc.setTime(hours, minutes, seconds);
// rtc.setDate(day, month, year);
rtc.setAlarmTime(00, 1, 00);
rtc.enableAlarm(rtc.MATCH_MMSS);
minutes+=1;
rtc.attachInterrupt(alarmMatch);
// delay(10000);
// loraSerial.write(“sys sleep 60000”);
// delay(10000);
// LoRaBee.sleep();
// loraSerial.println(“sys sleep 80000”);
delay(10000);
loraSerial.print("sys sleep ");
loraSerial.println(sleepTime);
delay(100);
// trace(“Sleeping…”);
//str = loraSerial.readStringUntil(’\n’);
//trace(str);
rtc.standbyMode();
}
void loop()
{
if(rtc_flag)
{
wakeup();
rtc.disableAlarm();
rtc_flag = false;
digitalWrite(LED_BUILTIN, HIGH);
debugSerial.println(“autonomo woke up”);
delay(5000);
minutes+=1;
rtc.setAlarmTime(00,minutes,00);
rtc.enableAlarm(rtc.MATCH_MMSS);
digitalWrite(LED_BUILTIN, LOW);
loraSerial.print("sys sleep ");
loraSerial.println(sleepTime);
delay(100);
}
rtc.standbyMode(); // Sleep until next alarm match
}
void alarmMatch()
{
rtc_flag = true;
}
void wakeup(){
Serial1.end();
pinMode(PIN_SERIAL1_TX, OUTPUT);
digitalWrite(PIN_SERIAL1_TX, LOW);
delay(5);
digitalWrite(PIN_SERIAL1_TX, HIGH);
Serial1.begin(57600);
Serial1.write(0x55);
}