DeepSleep Mode -13uA without LoRa.begin() - 290uA with LoRa.begin

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-14uA, 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. 290uA.

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 - MKRWAN1310 - Arduino Forum of it being possible to get down to the 14-15uA range - or in his follow up message 100uA, 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 290uA - the spec for the project is 2 years, so 100uA would do. Of course 13-14uA 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


1 Like

I have now spent many more hours bashing my head against this particular brick wall... It was suggested to me to see if forcing a device reset would bring the consumption back down after a radio send.

I found a blog post about using a digital I/O pin to force a reset and found that the power up state of the i/o pins on the MKR 1310 WAN are such that it causes a permanent reset cycle (LED just stays on on the board).

I have been using an alternate sketch that sleeps for 16s before sending, sends and then loops or resets (depending on which test I was doing) - the first sleep cycle is reliably at 17uA but sleep cycles after a send are much, much higher.

I used the Adafruit_SleepyDog library and tried to use the watchdog timer to do it - this appeared to work initially, however, I was slightly suspicious that my multimeter seemed to get 'stuck' at a particular current (10ma) during all sleep cycles after the first one (the first sleep cycle shows the ideal 17uA) and that switching the range from uA to mA or vice-versa corrected the reading back to 17uA / 0.02mA without apparently affecting the operation (the timings of the packets being received by my receiver set-up didn't change) - this made me suspect some kind of issue with the multimeter. However, I've now double checked by checking the voltage drop that occurs when using a primary cell and the first sleep cycle is definitely better (higher voltage) than sleep cycles after a radio send.

I'm wondering now about a circuit using a transistor that briefly 'blips' the power to the whole board when I set one of the digital pins high to do a 'hard' reset - however that will need to wait until I have more parts to hand.

Hi Alex,

I have seen this and gone back to post the code, it was really simple and I think you were probably already close.

However, I never did get to the point where I could run at these very low levels and still have edge interrupts. I fixed the millis problem, using delay micros instead as this still runs.

Hope this helps, although I am about to post another question to see if I can get help with clocks.

Thanks to the author of the LoRa library and a bit of experimentation and looking at the MKR1310 schematics I've managed to get down to a sleep current of 17uA - the code is as follows:

#include "ArduinoLowPower.h"
#include <LoRa.h>
#include <MKRWAN.h>

LoRaModem modem;

void setup() {
 // Set digital pins to input to reduce battery consumption
 for (int i=0; i < 15; i++) {
   pinMode(i, INPUT_PULLUP);
  }
  pinMode(LED_BUILTIN, OUTPUT);

  digitalWrite(LED_BUILTIN, HIGH);
  delay(3000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
 
}

void loop() {
  USBDevice.detach();

  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);

  pinMode(2, INPUT);
  pinMode(5, INPUT);

  LowPower.deepSleep(8000);
  //Watchdog.sleep(); //16s

  LoRa.begin(868E6);
  LoRa.beginPacket();
  LoRa.print("D:");
  LoRa.endPacket();
  LoRa.end();

  digitalWrite(LORA_RESET, LOW);
  digitalWrite(LORA_BOOT0, LOW);
  pinMode(LORA_RESET, INPUT);
  pinMode(LORA_DEFAULT_SS_PIN, INPUT);
  pinMode(LORA_IRQ_DUMB, INPUT);
  pinMode(LORA_BOOT0, INPUT);
 
}

My 'real' application is still using 20uA over this so I guess I still have a pin or two that's ending up in the wrong state - but that's unrelated to the LoRa sending.

Hope this helps someone else!

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.