I'm trying to get the MKR1310 to sleep 'properly' after sending with the LoRa radio. If I run the following code running with power on VCC and the SJ1 jumper cut:
#include "ArduinoLowPower.h"
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
// Set digital pins to input to reduce battery consumption
for (int i = 0; i < 15; i++) {
pinMode(i, INPUT_PULLUP);
}
}
void loop() {
USBDevice.detach();
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
LowPower.deepSleep(2000);
}
Then I measure a sleep current of 13-14 uA, however, once I add in Lora sending as in this code:
#include "ArduinoLowPower.h"
#include <LoRa.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
// Set digital pins to input to reduce battery consumption
for (int i = 0; i < 15; i++) {
pinMode(i, INPUT_PULLUP);
}
}
void loop() {
USBDevice.detach();
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
LoRa.begin(868E6);
LoRa.beginPacket();
LoRa.print("D:");
LoRa.endPacket();
LoRa.end();
digitalWrite(LORA_IRQ_DUMB, LOW);
digitalWrite(LORA_RESET, LOW);
digitalWrite(LORA_BOOT0, LOW);
pinMode(LORA_BOOT0, INPUT_PULLUP);
LowPower.deepSleep(2000);
}
Then I get a current of approx. 290 uA.
So clearly something isn't properly turning off / shutting down or I'm missing changing a pinMode back to how it was before LoRa.begin();.
I've searched these forums and google and read the threads and people's sample code, I've tried various pinModes at the end, I've reviewed both the MKRWAN and LoRa source code but still can not seem to spot what the issue is.
I've seen report from @mattb1969 in How can I achieve the 104µA power consumption? - #11 by mattb1969 of it being possible to get down to the 14-15 uA range - or in his follow up message 100 uA, but sadly he didn't include sample code.
Even 100uA would be satisfactory for my application - my calculations show that I'd get 0.9 years battery life with a sleep of 290 uA - the spec for the project is 2 years, so 100 uA would do. Of course 13-14 uA would be even better and I know the board is capable of it if I can just figure out how to get the board back to the state it is in before I do LoRa.begin();.
Thanks in advance for any help!
Alex