Skip to content

Commit

Permalink
added example sketch documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cristidragomir97 committed Jun 6, 2024
1 parent 174fb98 commit 3782007
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 37 deletions.
6 changes: 6 additions & 0 deletions examples/Charger/Charger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
- Open the Serial Monitor in the Arduino IDE.
- Set the baud rate to 115200.
- You will see the sketch continuously printing charger state information.
Please note that the Portenta C33 will not charge bateries that do not have an NTC.

Check failure on line 28 in examples/Charger/Charger.ino

View workflow job for this annotation

GitHub Actions / spellcheck

bateries ==> batteries
Original author: C. Dragomir (http://arduino.cc)
*/

#include "Arduino_PowerManagement.h"

Charger charger;
Expand Down
27 changes: 26 additions & 1 deletion examples/Standby_WakeFromPin/Standby_WakeFromPin.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
Standby Wake From Pin Demo
This sketch demonstrates how you can use the Arduino_PowermManagement library to send a board to standby mode by using a GPIO pin and wake it up from another.
This sketch is universal and worksn on both Portenta C33 and H7.
On the the Portenta C33 you can select any of the supported pins (A0, A1, A2, A3, A4, A5, D4, D7) to wake up the board from standby mode,
but on the Portenta H7 only GPIO0 can be used to wake up the board from standby mode. GPIO0 is available trough the High Density Connectors and you need a breakout board to access it.

Check failure on line 8 in examples/Standby_WakeFromPin/Standby_WakeFromPin.ino

View workflow job for this annotation

GitHub Actions / spellcheck

trough ==> through
Requirements:
- Arduino Portenta C33, Arduino Portenta H7
- Arduino IDE / Arduino CLI
- PowerManagement library (installable from the Arduino Library Manager)
Usage:
- Connect a button to GOTO_SLEEP_PIN and with a pull-up resistor to 3.3V
- Connect a button to pin PORTENTA_C33_WAKEUP_PIN if you are using the Portenta C33 or GPIO0 if you are using a Portenta H7 and with a pull-up resistor to 3.3V
(If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
- Upload the provided sketch to the board
- Press the button connected to GOTO_SLEEP_PIN to put the board into standby mode
- Press the button connected to PORTENTA_C33_WAKEUP_PIN or GPIO0 to wake up the board from standby mode
- The LED will blink every second to show that the board is awake when not in standby mode
Original author: C. Dragomir (http://arduino.cc)
*/

#include "Arduino.h"
#include "Arduino_PowerManagement.h"
Expand All @@ -13,7 +38,7 @@ Board board;
void setup() {
board = Board();
board.begin();
board.setAllPeripheralsPower(true);
board.setAllPeripheralsPower(true); // TODO: Check if this is necessary

// Allows to use a button to put the device into sleep mode
attachInterrupt(digitalPinToInterrupt(GOTO_SLEEP_PIN), goToSleep, RISING);
Expand Down
27 changes: 22 additions & 5 deletions examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
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.
Effectivelly, you will get the same effect as with blink.

Check failure on line 6 in examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino

View workflow job for this annotation

GitHub Actions / spellcheck

Effectivelly ==> Effectively
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
Original author: C. Dragomir (http://arduino.cc)
*/


#include "Arduino_PowerManagement.h"
#include "RTC.h"
Expand All @@ -14,8 +33,6 @@ 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(LED_BUILTIN, OUTPUT);
Expand All @@ -31,8 +48,8 @@ void setup() {
}
}


board.setAllPeripheralsPower(true); // TODO: Check if this is necessary

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

RTC.begin();
Expand All @@ -45,11 +62,11 @@ void setup() {
}

// board.enableWakeupFromRTC(0, 0, 10, [](){}); // Sleep for 10 seconds
board.enableWakeupFromRTC(0, 0, 10); // Sleep for 10 seconds
board.enableWakeupFromRTC(0, 0, 1); // Sleep for 10 seconds

delay(1000); // Keep the board awake for 1 second, so we can se it working

board.setAllPeripheralsPower(false);
board.setAllPeripheralsPower(false); // turn off peripherals before going to sleep
board.standByUntilWakeupEvent();
}

Expand Down
49 changes: 18 additions & 31 deletions examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
/*
Charger Demo
This sketch demonstrates how to use the PowerManagement library enable low power modes on the Arduino Portenta H7.
* In the setup() function, it enters standby mode and waits for a wakeup event from the RTC.
* The loop() functionit is not used in this sketch.
IMPORTANT: Please note that this sketch has to be uploaded to the M4 core too in order to achieve the lowest power consumption.
Requirements:
- Arduino Arduino Portenta H7
- Arduino IDE
- PowerManagement library (installable from the Arduino Library Manager)
Usage:
1. Connect a battery to the board.
2. Upload the Sketch to the M4 core:
- Open the provided sketch in the Arduino IDE.
- Select your board type and port from the "Tools" menu.
- Select the M4 core from the "Tools" menu.
- Click the "Upload" button to upload the sketch to your board.
3. Upload the Sketch to the M7 core:
- Select the M7 core from the "Tools" menu.
- Click the "Upload" button to upload the sketch to your board.
4. Observer LED behavior:
- The blue LED will turn on when the board is awake.
- The blue LED will turn off when the board goes to sleep.
- The red LED will blink if the board fails to initialize.
Standby Wake from RTC Demo for Portenta H7
This example demonstrates how to wake up the Portenta H7 from standby mode using the included RTC (Real Time Clock).
The device will go to sleep for 10 second and then stay awake for another 10. When the device is awake you will see the board's blue LED turned on.
Effectivelly, you will get the same effect as with blink.

Check failure on line 6 in examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino

View workflow job for this annotation

GitHub Actions / spellcheck

Effectivelly ==> Effectively
On the Portenta H7 with the peripherals turned off you can expect around 300uA 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 H7 board from the Tools men
- Select the Portenta H7 USB port from the Tools menu
- Upload the code to your Portenta H7
Original author: C. Dragomir (http://arduino.cc)
*/

#include "Arduino_PowerManagement.h"
Expand Down Expand Up @@ -74,6 +60,7 @@ void setup() {
fuelgauge.setOperationMode(FuelGaugeOperationMode::shutdown);
delay(10000); // keep the board awake for 10 seconds, so we can se it working


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

Expand Down

0 comments on commit 3782007

Please sign in to comment.