Go Down

Topic: Compilation issues with ArduinoLowPower library for Samd21 processors (Read 319 times) previous topic - next topic

katesfb

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:

Code: [Select]
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.

pert

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:
https://github.com/arduino/ArduinoCore-samd/commit/b9ac48c782ca4b82ffd7e65bf2c956152386d82b
You might try applying that patch to your SODAQ SAMD Boards core files to see what happens.

katesfb

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.

pert

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.

pert

I should also correct my previous statement:
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.

katesfb

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;

Code: [Select]
#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.

pert

I made the changes to the relevant files and it now compiles
Way cool! Nice work.

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

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?

i also have to disconnect from serial monitor
What happens if you're connected to Serial Monitor?

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.

Go Up