Compilation issues with ArduinoLowPower library for Samd21 processors

Hi,
I have a Sodaq autonomo board (based on samd21 processor - https://support.sodaq.com/sodaqone/autonomо/) and i am trying to use the ArduinoLowPower library with it and the timedWakeup example sketch however compilation fails with the error:

Arduino: 1.8.5 (Linux), Board: "SODAQ Autonomo with Serial2"


/home/richard/Dev/ArdSketches/libraries/Arduino_Low_Power/src/samd/ArduinoLowPower.cpp: In member function 'void ArduinoLowPowerClass::sleep()':
/home/richard/Dev/ArdSketches/libraries/Arduino_Low_Power/src/samd/ArduinoLowPower.cpp:21:13: error: 'class USBDeviceClass' has no member named 'standby'
   USBDevice.standby();

However it compiles fine if i compile using the MKRZero board which has the same processor.

All libraries and board information is up to date for the arduino IDE.

Can anybody suggest what may be going on here?

Any help i much appreciated.

Cheers.

The problem is that the newest version of SODAQ SAMD Boards (1.6.19) has the core library code equivalent to Arduino SAMD Boards 1.6.19. The standby function was added in Arduino SAMD Boards 1.6.20 last November but SODAQ still hasn't bothered to update their code.

Here is the change that was made to the Arduino SAMD Boards core library:

You might try applying that patch to your SODAQ SAMD Boards core files to see what happens.

Hi Pert,
And thanks for the reply. The link you supplied shows 4 changed files however i dont have one of those files in my Arduino IDE at all (samd21_usbdevice.h). I have checked the latest version (1.8.9) and that also does not have it - would there be any reason why that file is missing or is it for use with other arduino IDE's like Arduino Studio.

Any help is much appreciated.

Cheers.

That file wouldn't be in the Arduino IDE because Arduino SAMD Boards is not part of the Arduino IDE. Arduino SAMD Boards (and Sodaq SAMD Boards) are installed to a completely separate location. In the case of Arduino SAMD Boards, it's at ~/.arduino15/packages/arduino/hardware/samd. The only hardware package bundled with your Arduino IDE 1.8.9 is Arduino AVR Boards.

I should also correct my previous statement:

pert:
The standby function was added in Arduino SAMD Boards 1.6.20 last November

I looked again, and the standby function was added in Arduino SAMD Boards 1.6.13, two years ago. So Sodaq is way behind the times with their code.

Hi Pert,
and thanks for the reply.

I made the changes to the relevant files and it now compiles - so thanks for you help with that. However i have noted some odd behavior;

  1. when using the LowPower.idle() method with the TimdewakeUp example, it does not work. I thought that this may have been due to missing "PM->SLEEP.bit.IDLE = PM_SLEEP_IDLE(0);" from the *.cpp file however adding this had no effect.

  2. when using the LowPOwer.Sleep() method with the TimdewakeUp example it works fine and the following script also worked but only if i changed "RTCZero rtc;" to "RTCZero _RTC;" i think that this is because ArduinoLowPower uses RTCZero.h and i think there is a conflict of data types, i also have to disconnect from serial monitor;

#include "ArduinoLowPower.h"

RTCZero _RTC;    //RTCZero rtc; did not work - conflict?
#define ser SerialUSB

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

  ser.begin(9600);
  while ((!ser) && (millis() < 10000));
  ser.println("Serial monitor opened...");

  setupRTC();

  delay(1000);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);

  String message = String(_RTC.getYear())+"-"+String(_RTC.getMonth())+"-"+String(_RTC.getDay());
  message += "  ";
  message += String(_RTC.getHours())+":"+String(_RTC.getMinutes())+":"+String(_RTC.getSeconds());
  ser.println(message);
  
  LowPower.sleep(5000);
}

void setupRTC() {
  ser.print(F("setup RTC..."));
  
  _RTC.begin(); // initialize RTC
  //_RTC.setEpoch(epoch); // Jan 1, 2016
  _RTC.setEpoch(1552276419);
  //_RTC.setEpoch(newTs);

  ser.print("Unix time = ");
  ser.println(_RTC.getEpoch());

  // Print date...
  ser.print(_RTC.getDay());
  ser.print("/");
  ser.print(_RTC.getMonth());
  ser.print("/");
  ser.print(_RTC.getYear());
  ser.print("\t");

  // ...and time
  print2digits(_RTC.getHours());
  ser.print(":");
  print2digits(_RTC.getMinutes());
  ser.print(":");
  print2digits(_RTC.getSeconds());
  ser.print("\n");
}

void print2digits(int number) {
  if (number < 10) {
    ser.print("0");
  }
  ser.print(number);
}

However if i increase the complexity of the code in the main loop it hangs on entering sleep whereas the code runs fine without the call to sleep and i am not sure why this should be. The extra code is just more time checking calls to RTCZero time library) and if a certain time is reached it runs off does some logging to a file but it is actually hanging before it gets to this point although it still does suggest a library conflict somewhere.

If you have any ideas on this they would be much appreciated.

Cheers.

katesfb:
I made the changes to the relevant files and it now compiles

Way cool! Nice work.

katesfb:

  1. when using the LowPower.idle() method with the TimdewakeUp example, it does not work.

Have a read of this thread:
http://forum.arduino.cc/index.php?topic=601522.0

katesfb:
the following script also worked but only if i changed "RTCZero rtc;" to "RTCZero _RTC;"

Did the code not compile before you made that change?

katesfb:
i also have to disconnect from serial monitor

What happens if you're connected to Serial Monitor?

katesfb:
However if i increase the complexity of the code in the main loop it hangs on entering sleep whereas the code runs fine without the call to sleep and i am not sure why this should be. The extra code is just more time checking calls to RTCZero time library) and if a certain time is reached it runs off does some logging to a file but it is actually hanging before it gets to this point although it still does suggest a library conflict somewhere.

Please post the shortest code that still causes the problem.

Disclaimer: There is a good chance I still won't be able to answer your questions even after you provide the requested information, but I think anyone else here who does has the necessary knowledge to help will first need this information so I'm at least doing the groundwork for them.