The following information and components make it possible to adjust the operating-, sleep- and wakeup behaviour of the device to the system requirements. See also the LowPowerSAMC- Library.

Operation modes

OFF

ON

SLEEP

* The system wakes up from sleep mode when it is triggered by an internal (RTC) or external interrupt (e.g. CAN, motion etc.). see ‘Sleep mode / Wakeup configuration’ here.

Signals / block diagram

After power-on ( or reset), the system sets the SELFHOLD signal HIGH. This keeps the device running even if IGNITION will be switched off.
Switching OFF: If the ignition signals goes low, the application would have to set SELFHOLD to LOW in order to switch the device fully off.
Enter sleep-mode: If the device shall enter sleep-mode instead so to wake up by any trigger other than the ignition pin, the application would have to keep SELFHOLD high, configure the desired wakeup sources and then go to sleep(); Be aware that before entering sleep mode, the application should also uninitialize any peripheral interfaces and libraries (e.g. WiFi.end() etc.). After waking up from sleep mode, it is highly recommended to perform a v_resetSystem() to enable a fresh system start and initialization.

Read UB (supply voltage)

Read IGNITION

Switch off (SELFHOLD)

Note: find further examples in the Arduino example menu under
DICE -> 6_Power_Sleep and
Low Power SAMC ->

Reset

The (global) function v_resetSystem() restarts the system. It is recommended to call it after a sleep() command. The latest reason for the wakeup (e.g. wakeup by CAN traffic) will still be available after reset. See u32_getWakeUpReason() function).

Sleep mode / Wakeup configuration

The LowPowerSAMC- Library provides methods to configure the wakeups and put the device into sleep mode. Example:

LowPower.setWkUpSources(LOWPOWER_WKUP_IGN | LOWPOWER_WKUP_ACC);
// Close periphery and files: eg. WiFi.end()
LowPower.sleep();
v_resetSystem();

Getting the reason for system start / reset

The function u32_getWakeUpReason() delivers the latest reason for the system to run. This information is always available even after a v_resetSystem(). Reasons are defines like e.g. LOWPOWER_WKUP_ACC in case the system was woken up by motion. The application could use this information to act differently (e.g. sending an alarm) depending on the wake up reason. Find the WkUp defines in the right column of this page.

if(u32_getWakeUpReason() & LOWPOWER_WKUP_ACC)
   Serial.println(" - MOTION WAKEUP -");

Note: There is also the global function v_setWakeUpReason(uint32_t wkup) which allows to manually change the reason for wakeup. This function might help in cases when the user application wants to change its behaviour. For example if during a nightly wakeup a user switches the ignition on. In such case it might be helpful to change the wkup-reason and reset the device. Use the defines (LOWPOWER_WKUP_xxx) in the right column of this page for the wkup argument of the function.

See example
DICE -> 6_Power_Sleep -> AllWakeups

Shutting down system periphery

Suggested shutdown commands for modules, libraries and interfaces (depending on the hardware variant, object names and libraries used) :

// disconnect & shutdown modules and interfaces e.g.:
WiFi.end();
BLE.end();
GSM.shutdown();
// close files in SerialFlash a/o on SD card e.g.:
myFile.close();
SD.end(); 

Example in Arduino IDE:
Examples -> DICE -> 6_Power_Sleep -> WiFiPingOnceAnHour

Notes:

It is good practise (and particularly required for modems) to perform an orderly deregistration / shutdown process of the peripheral modules (e.g. modems of dice-IoT, dice-WiFi) before the system is reset or shut off. This is because the mobile networks (LTE provider) expects this from its mobiles. There is also a risk that the cellular modem will be damaged if the power supply is interrupted while it is writing to the internal flash memory. At the same time, by using WiFi.end() / BLE.end() / GSM.shutdown() etc. the associated interfaces (e.g UART, SPI) are also disabled. This is necessary to achieve the lowest possible standby power consumption when entering SLEEP mode.

Also consider closing all open files in SerialFlash and/or on the SD-Card before going to sleep or before shutting down. This is particularly important for files on the SD-Card in order to not loose data or risk a corrupted file system on the card. (note that sleep() also cuts the power supply of the SD-card interface)

Further information:

LowPowerSAMC- Library
RTCSAMC – Library
UsersManual – Bockdiagrams, Low power current consumption

Signals, functions & defines:

Defines (global):

  • LOWPOWER_WKUP_POR
  • LOWPOWER_WKUP_IGN
  • LOWPOWER_WKUP_RTC
  • LOWPOWER_WKUP_ACC
  • LOWPOWER_WKUP_CAN0
  • LOWPOWER_WKUP_CAN1
  • LOWPOWER_WKUP_USB
  • LOWPOWER_WKUP_APP
  • LOWPOWER_WKUP_WDT
  • ERROR_INTERRUPT_DUMMY_HANDLER
  • ERROR_INTERRUPT_HARDFAULT

Functions:

Signals:

  • IGNITION (in)
  • SELFHOLD (out)
  • LED_BUILTIN (out)
  • getUBatt (float)