-
Notifications
You must be signed in to change notification settings - Fork 2
/
Standby_WakeFromRTC_C33.ino
68 lines (52 loc) · 2.23 KB
/
Standby_WakeFromRTC_C33.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Standby Wake from RTC Demo for Portenta C33
This example demonstrates how to wake up the Portenta C33 from standby mode using the included RTC (Real Time Clock).
The device will go to sleep for 5 seconds and then wake up. When the device is awake you will see the board's built-in LED turned on.
Effectively, you will get the same effect as with blink.
On the Portenta C33 with the peripherals turned off you can expect around 60uA of current consumption in standby mode.
The example also turns off the peripherals before going to sleep and turns them back on after waking up.
Usage:
- Make sure you are running the latest version of the Renesas Core
- Select the Portenta C33 board from the Tools menu
- Select the Portenta C33 USB port from the Tools menu
- Upload the code to your Portenta C33
Initial author: Cristian Dragomir ([email protected])
*/
#include "Arduino_PowerManagement.h"
#include "RTC.h"
RTCTime initialTime(1, Month::JANUARY, 2000, 12, 10, 00, DayOfWeek::SATURDAY, SaveLight::SAVING_TIME_ACTIVE);
Board board;
void blinkLed(int ledPin, int delayTime = 1000){
digitalWrite(ledPin, LOW);
delay(delayTime);
digitalWrite(ledPin, HIGH);
delay(delayTime);
}
void setup() {
pinMode(LEDR, OUTPUT); // Used to indicate errors
digitalWrite(LEDR, HIGH); // Turn off the red LED
pinMode(LED_BUILTIN, OUTPUT); // Used to indicate that the board is awake
if(!board.begin()){
while (true){
blinkLed(LEDR);
}
}
board.setAllPeripheralsPower(true);
digitalWrite(LED_BUILTIN, LOW); // Turn on the LED to show that the board is awake
RTC.begin();
if (!RTC.isRunning()) {
// The initial time is a dummy time
// You could also get the actual time from an NTP server or from a user input
if(!RTC.setTime(initialTime)){
while (true){
blinkLed(LEDR);
}
}
}
delay(5000); // Keep the board awake for 5 seconds, so we can se it working
board.enableWakeupFromRTC(0, 0, 5); // Sleep for 5 seconds
board.shutDownFuelGauge();
board.setAllPeripheralsPower(false);
board.standByUntilWakeupEvent();
}
void loop(){}