Go Down

Topic: MKR 1000 and issue serial com after LowPower.sleep (Read 873 times) previous topic - next topic

hppp

Hello everybody,

I just finish temperature and humidity sensors with MKR 1000 and now, I would like optimise the
consumption power with ArduinoLowPower.h librairie

So, I put at the End to the loop, LowPower.sleep(2000); command, but when the MKR wake up, I loss totaly the serial communication, and never work again, and I need to reboot the board.

Have you a idea ?

Thank you for your help

My code :
Code: [Select]

/*
  TimedWakeup
  This sketch demonstrates the usage of Internal Interrupts to wakeup a chip in sleep mode.
  Sleep modes allow a significant drop in the power usage of a board while it does nothing waiting for an event to happen. Battery powered application can take advantage of these modes to enhance battery life significantly.
  In this sketch, the internal RTC will wake up the processor every 2 seconds.
  Please note that, if the processor is sleeping, a new sketch can't be uploaded. To overcome this, manually reset the board (usually with a single or double tap to the RESET button)
  This example code is in the public domain.
*/

#include "ArduinoLowPower.h"

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Uncomment this function if you wish to attach function dummy when RTC wakes up the chip
  // LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, dummy, CHANGE);

  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial1.println("Start program");
  delay(5000);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
  // Triggers a 2000 ms sleep (the device will be woken up only by the registered wakeup sources and by internal RTC)
  // The power consumption of the chip will drop consistently
  Serial.println("sleep");
  LowPower.sleep(2000);
  Serial.println("wake");
}

void dummy() {
  // This function will be called once on device wakeup
  // You can do some little operations here (like changing variables which will be used in the loop)
  // Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
}

ballscrewbob

Have you tried it with the "while serial" section removed ?
Early MKR's needed that but more recent one and those with upgraded firmware should no longer need it.

Also not sure about this line in your sketch "Serial1.println("Start program");" which I think should be "Serial.println("Start program");"



It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

sandeepmistry

This is a limitation of the low power library, after waiting up the USB serial is not ready for use.

amirf

I am using MKR1400. While it is a good board for 3G connection I have same issue with power library which as an absolute rubbish.

amirf

The board works fine it is just serial connection. This is likely to be a mess up between Arduino IDE, Windows and the board as I see when the board wakes up there is a few port open and likely to confuse Arduino IDE.

Go Up