This library allows to put the device into low power mode (sleep mode). It provides functions to select the trigger sources that will cause the device to wake up:
- RTC – time based (e.g. after 1 hour (3600000 ms))
- CAN0 / CAN1 – traffic – ISO-defined pattern on the selected bus(es)
- Motion – of the device
- IGN – a L/H transition on the ignition pin (further DINs are also possible)
- USB – USB host connection event
During sleep mode dice-devices still maintain:
- the RTC (so that time / date will still be available after wakeup)
- the acceleration sensor (to trigger the wakeup from motion of the device)
- GPS (e.g. for applicable devices with embedded receiver dice-GNSS etc.) which let the (TTFF – time to first fix) be reduced significantly after wakeup.
- monitoring the CAN bus for the ISO-defined wakeup pattern on the bus.
- ignition pin (& possibly further DINs) level transitions triggering wakeup.
After waking up the library function sleep() returns the reason for the wakeup to the calling application. It is strongly recommended to perform a system reset ( v_resetSystem()
) after wakeup so that the entire system initialises its interfaces and registers correctly.
To use this library
#include "LowPowerSAMC.h"
By including the library, an object will be created that can be used for the operations:
LowPower
Example usage:
LowPower.setWkUpSources(LOWPOWER_WKUP_CAN0);
LowPower.sleep();
v_resetSystem();
Example
#include "LowPowerSAMC.h"
void setup()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(2000);
}
void loop()
{
LowPower.setWkUpSources( LOWPOWER_WKUP_CAN0 |
LOWPOWER_WKUP_IGN );
LowPower.sleep(10000);
v_resetSystem();
}
LowPowerSAMC library notes / compatibility
It is important to stop all communication libraries and associated interfaces before entering into the sleep mode. The reason for this is that the power supplies of the communication modules (e.g. Wifi or GSM modem) will be switched off during sleep mode. The connected low level interfaces (SPI, UART) would cause undesired currents if they remained active. See examples of how to prepare the device / application before going into sleep mode e.g. in the “Console” demo applications source code (consoleRTC.cpp).
The internal signal SELFHOLD
keeps the systems power supply running even when the ignition pin is switched off. This enables the application to decided when / if it likes to switch the device off or to put it into sleep mode instead. At start up, this signal is switched on by default. This is why the example above allows the user to switch the ignition pin off/on and use it as a wake up trigger without losing power.
Numerous wake ups
The reason for the many wakeup opportunities is to make the devices suitable for multiple application scenarios:
- for cases where the traget machine would either not provide an ignition signal at all or it is not available at the particular mounting location using CAN wake up could control the device operation mode instead.
- Intervals. The RTC wakeup can be used for application that should do certain jobs at a certain time / interval. E.g. delivering data during night time while it is idle.
- Theft protection application facilitating motion wakeups.
Libraries compatibilities
The LowPowerSAMC library auto-includes the RTCSAMC.h library that creates the rtc
object. This object is used by the library to have the RTC doing timed wakeups (e.g. sleep(1000);
As mentioned above, it is recommended to perform a v_resetSystem()
after the sleep mode to give the system a fresh restart.
Please also note, that the global function u32_getWakeUpReson()
is provided to let the application determine what triggered the current start/reset. See more details in the technical article Power & Reset management.
Further information
Power and Reset management – details about start-, operation-, reset- and sleep-modes
dice users manual – details about device capabilities, possible wake up sources and electrical interfaces to be considered before entering sleep mode.
RTCSAMC – library to work with the internal real time clock
DICE_GPS – shares GPS (also time) information between dice-devices
LowPowerSAMC-class
Methods:
Defines:
- LOWPOWER_WKUP_IGN
- LOWPOWER_WKUP_RTC
- LOWPOWER_WKUP_ACC
- LOWPOWER_WKUP_CAN0
- LOWPOWER_WKUP_CAN1
- LOWPOWER_WKUP_USB
Further functions (global):