Author Topic: 'class LowPowerClass' has no member named 'powerDown'  (Read 190 times)

abucknum

  • Newbie
  • *
  • Posts: 2
'class LowPowerClass' has no member named 'powerDown'
« on: June 10, 2019, 09:14:25 PM »
I am attempting to use the LowPower library at https://github.com/LowPowerLab/LowPower using a Moteino M0. When I attempt to compile the example "powerDownWakePeriodic", I get the following error:

Code: [Select]
C:\Users\skier\AppData\Local\Temp\arduino_modified_sketch_79047\powerDownWakePeriodic.ino: In function 'void loop()':

powerDownWakePeriodic:12:14: error: 'class LowPowerClass' has no member named 'powerDown'

     LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 

              ^

exit status 1
'class LowPowerClass' has no member named 'powerDown'

However, when I select Moteino / Moteino USB in Tools => Board, the code compiles fine. I can't seem to find anything wrong with the code, is there something I am missing?

Using:
- Arduino IDE 1.8.9
- Tried 1.2.0, 1.1.0, and 1.0.0 LowPowerLab SAMD Boards in Boards Manager with same results

Thanks!


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6004
  • Country: us
    • LowPowerLab
Re: 'class LowPowerClass' has no member named 'powerDown'
« Reply #1 on: June 10, 2019, 09:30:46 PM »
That example is for AVR.
For SAMD use this example:
https://github.com/LowPowerLab/LowPower/blob/master/Examples/standbyExternalInterruptSAMD21/standbyExternalInterruptSAMD21.ino

Or if you want periodic waking for SAMD21 you can use the RTCZero library, here's a modded example of that for MOTEINO_M0:

Code: [Select]
#include <RTCZero.h>

RTCZero zerortc;

// Set how often alarm goes off here
const byte alarmSeconds = 3;
const byte alarmMinutes = 0;
const byte alarmHours = 0;

volatile bool alarmFlag = false; // Start awake

#if defined (MOTEINO_M0)
  #if defined(SERIAL_PORT_USBVIRTUAL)
    #define Serial SERIAL_PORT_USBVIRTUAL // Required for Serial on Zero based boards
  #endif
#endif

void setup()
{
  Serial.begin(115200);
  delay(3000); // Wait for console
 
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  zerortc.begin(); // Set up clocks and such
  pinMode(PIN_ATN, OUTPUT);
  resetAlarm();  // Set alarm
  zerortc.attachInterrupt(alarmMatch); // Set up a handler for the alarm
}

void loop()
{
  if (alarmFlag == true) {
    alarmFlag = false;  // Clear flag
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(PIN_ATN, HIGH);
    delay(1300);
    Serial.println("Alarm went off - I'm awake!");
  }
  resetAlarm();  // Reset alarm before returning to sleep
  Serial.println("Alarm set, going to sleep now.");
  digitalWrite(LED_BUILTIN, LOW);
  digitalWrite(PIN_ATN, LOW);
  zerortc.standbyMode();    // Sleep until next alarm match
}

void alarmMatch(void)
{
  alarmFlag = true; // Set flag
}

void resetAlarm(void) {
  byte seconds = 0;
  byte minutes = 0;
  byte hours = 0;
  byte day = 1;
  byte month = 1;
  byte year = 1;
 
  zerortc.setTime(hours, minutes, seconds);
  zerortc.setDate(day, month, year);

  zerortc.setAlarmTime(alarmHours, alarmMinutes, alarmSeconds);
  zerortc.enableAlarm(zerortc.MATCH_HHMMSS);
}

abucknum

  • Newbie
  • *
  • Posts: 2
Re: 'class LowPowerClass' has no member named 'powerDown'
« Reply #2 on: June 11, 2019, 01:42:40 AM »
Ah - thanks for the quick response!