Hi all,
I read this post with interest and then purchased a MKR WAN 1310. I’ve taken the code that is posted by thomasguenzel and using an simple hardware set-up, measured the current - 9mA.
My hardware setup is a 5V feed into Vin & GND with an ammeter in the line.
So I removed the power LED, it now runs at 1.9mA.
I have tried turning the Serial Flash off, turning off LoraWan via GPIO, but it actually rose to 2.1mA!I have tried various libraries, ArdunioLowPower, LowerPower by RocketStream, even using the RTC library (modified) with standby, but they all sit at 1.9mA.
I am sure I am missing something obvious, but how do I even get below 1mA??
The latter challenge I will have is that I want to also have external interrupts running and the RTC timer, but I’m stuck at this high level of power consumption without even working out how to still have some interrupts running.
Code:
/*
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
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"
//#include "LowPower.h"
#include <SerialFlash.h>
#include <ArduinoLowPower.h>
/* Create an rtc object */
RTCZero rtc;
/* Change these values to set the current initial time */
const byte seconds = 0;
const byte minutes = 0;
const byte hours = 0;
/* Change these values to set the current initial date */
const byte day = 0;
const byte month = 0;
const byte year = 0;
void setup()
{
// Set digital pins to input
for (int i=0; i < 15; i++) {
pinMode(i, INPUT_PULLUP);
}
//pinMode(LORA_RESET, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(2000);
digitalWrite(LED_BUILTIN, LOW);
rtc.begin();
rtc.setTime(hours, minutes, seconds);
rtc.setDate(day, month, year);
rtc.setAlarmTime(0, 0, 25);
rtc.enableAlarm(rtc.MATCH_HHMMSS);
rtc.attachInterrupt(alarmMatch);
USBDevice.detach();
//SerialFlash.begin(SPI1, FLASH_CS);
//delay(500);
//SerialFlash.sleep();
//digitalWrite(LORA_RESET, LOW);
}
void loop()
{
//LowPower.standby(); // Sleep until next alarm match
//LowPower.idle(IDLE_0);
LowPower.deepSleep();
}
void alarmMatch()
{
digitalWrite(LED_BUILTIN, HIGH);
USBDevice.attach();
}