Skip to content

Commit

Permalink
Simplify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Aug 23, 2024
1 parent ff125ed commit d0f5d28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
12 changes: 7 additions & 5 deletions examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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 1 second and then wake up. When the device is awake you will see the board's blue LED turned on.
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.
Expand Down Expand Up @@ -35,7 +35,7 @@ void blinkLed(int ledPin, int delayTime = 1000){
void setup() {
pinMode(LEDR, OUTPUT); // Used to indicate errors
digitalWrite(LEDR, HIGH); // Turn off the red LED
pinMode(LEDB, OUTPUT); // Used to indicate that the board is awake
pinMode(LED_BUILTIN, OUTPUT); // Used to indicate that the board is awake

if(!board.begin()){
while (true){
Expand All @@ -44,19 +44,21 @@ void setup() {
}

board.setAllPeripheralsPower(true);
digitalWrite(LEDB, LOW); // Turn on the blue LED to show that the board is still awake
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(10000); // Keep the board awake for 10 seconds, so we can se it working
board.enableWakeupFromRTC(0, 0, 10); // Sleep for 10 seconds
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);
Expand Down
9 changes: 1 addition & 8 deletions examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ void setup() {
pinMode(LEDR, OUTPUT); // Used to indicate errors
digitalWrite(LEDR, HIGH); // Turn off the red LED
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH); // Turn off the built-in LED
pinMode(LEDB, OUTPUT); // Used to indicate that the board is awake
digitalWrite(LED_BUILTIN, LOW); // Turn on the built-in LED to show that the board is awake

// Turn on the blue LED to show that the board is still awake
digitalWrite(LEDB, LOW);


if(!board.begin()){
// If the board fails to initialize, it will blink the red LED
while (true){
Expand All @@ -58,8 +53,6 @@ void setup() {
delay(10000); // keep the board awake for 10 seconds, so we can se it working
board.shutDownFuelGauge();



// The LED should go off when the board goes to sleep
board.setAllPeripheralsPower(false);

Expand Down

0 comments on commit d0f5d28

Please sign in to comment.