Skip to content

Commit 3782007

Browse files
added example sketch documentation
1 parent 174fb98 commit 3782007

File tree

4 files changed

+72
-37
lines changed

4 files changed

+72
-37
lines changed

examples/Charger/Charger.ino

+6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
- Open the Serial Monitor in the Arduino IDE.
2424
- Set the baud rate to 115200.
2525
- You will see the sketch continuously printing charger state information.
26+
27+
28+
Please note that the Portenta C33 will not charge bateries that do not have an NTC.
29+
30+
Original author: C. Dragomir (http://arduino.cc)
2631
*/
32+
2733
#include "Arduino_PowerManagement.h"
2834

2935
Charger charger;

examples/Standby_WakeFromPin/Standby_WakeFromPin.ino

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
/*
2+
Standby Wake From Pin Demo
3+
4+
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.
5+
This sketch is universal and worksn on both Portenta C33 and H7.
6+
7+
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,
8+
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.
9+
10+
Requirements:
11+
- Arduino Portenta C33, Arduino Portenta H7
12+
- Arduino IDE / Arduino CLI
13+
- PowerManagement library (installable from the Arduino Library Manager)
14+
15+
Usage:
16+
- Connect a button to GOTO_SLEEP_PIN and with a pull-up resistor to 3.3V
17+
- 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
18+
(If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
19+
- Upload the provided sketch to the board
20+
- Press the button connected to GOTO_SLEEP_PIN to put the board into standby mode
21+
- Press the button connected to PORTENTA_C33_WAKEUP_PIN or GPIO0 to wake up the board from standby mode
22+
- The LED will blink every second to show that the board is awake when not in standby mode
23+
24+
Original author: C. Dragomir (http://arduino.cc)
25+
*/
126

227
#include "Arduino.h"
328
#include "Arduino_PowerManagement.h"
@@ -13,7 +38,7 @@ Board board;
1338
void setup() {
1439
board = Board();
1540
board.begin();
16-
board.setAllPeripheralsPower(true);
41+
board.setAllPeripheralsPower(true); // TODO: Check if this is necessary
1742

1843
// Allows to use a button to put the device into sleep mode
1944
attachInterrupt(digitalPinToInterrupt(GOTO_SLEEP_PIN), goToSleep, RISING);

examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
Standby Wake from RTC Demo for Portenta C33
3+
4+
This example demonstrates how to wake up the Portenta C33 from standby mode using the included RTC (Real Time Clock).
5+
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.
6+
Effectivelly, you will get the same effect as with blink.
7+
8+
On the Portenta C33 with the peripherals turned off you can expect around 60uA of current consumption in standby mode.
9+
The example also turns off the peripherals before going to sleep and turns them back on after waking up.
10+
11+
Usage:
12+
- Make sure you are running the latest version of the Renesas Core
13+
- Select the Portenta C33 board from the Tools menu
14+
- Select the Portenta C33 USB port from the Tools menu
15+
- Upload the code to your Portenta C33
16+
17+
Original author: C. Dragomir (http://arduino.cc)
18+
*/
19+
120

221
#include "Arduino_PowerManagement.h"
322
#include "RTC.h"
@@ -14,8 +33,6 @@ void blinkLed(int ledPin, int delayTime = 1000){
1433
}
1534

1635
void setup() {
17-
18-
1936
pinMode(LEDR, OUTPUT); // Used to indicate errors
2037
digitalWrite(LEDR, HIGH); // Turn off the red LED
2138
pinMode(LED_BUILTIN, OUTPUT);
@@ -31,8 +48,8 @@ void setup() {
3148
}
3249
}
3350

51+
3452
board.setAllPeripheralsPower(true); // TODO: Check if this is necessary
35-
3653
digitalWrite(LEDB, LOW); // Turn on the blue LED to show that the board is still awake
3754

3855
RTC.begin();
@@ -45,11 +62,11 @@ void setup() {
4562
}
4663

4764
// board.enableWakeupFromRTC(0, 0, 10, [](){}); // Sleep for 10 seconds
48-
board.enableWakeupFromRTC(0, 0, 10); // Sleep for 10 seconds
65+
board.enableWakeupFromRTC(0, 0, 1); // Sleep for 10 seconds
4966

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

52-
board.setAllPeripheralsPower(false);
69+
board.setAllPeripheralsPower(false); // turn off peripherals before going to sleep
5370
board.standByUntilWakeupEvent();
5471
}
5572

examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino

+18-31
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
11
/*
2-
Charger Demo
3-
4-
This sketch demonstrates how to use the PowerManagement library enable low power modes on the Arduino Portenta H7.
5-
* In the setup() function, it enters standby mode and waits for a wakeup event from the RTC.
6-
* The loop() functionit is not used in this sketch.
7-
8-
IMPORTANT: Please note that this sketch has to be uploaded to the M4 core too in order to achieve the lowest power consumption.
9-
10-
Requirements:
11-
- Arduino Arduino Portenta H7
12-
- Arduino IDE
13-
- PowerManagement library (installable from the Arduino Library Manager)
14-
15-
Usage:
16-
17-
1. Connect a battery to the board.
18-
19-
2. Upload the Sketch to the M4 core:
20-
- Open the provided sketch in the Arduino IDE.
21-
- Select your board type and port from the "Tools" menu.
22-
- Select the M4 core from the "Tools" menu.
23-
- Click the "Upload" button to upload the sketch to your board.
24-
25-
3. Upload the Sketch to the M7 core:
26-
- Select the M7 core from the "Tools" menu.
27-
- Click the "Upload" button to upload the sketch to your board.
28-
29-
4. Observer LED behavior:
30-
- The blue LED will turn on when the board is awake.
31-
- The blue LED will turn off when the board goes to sleep.
32-
- The red LED will blink if the board fails to initialize.
2+
Standby Wake from RTC Demo for Portenta H7
3+
4+
This example demonstrates how to wake up the Portenta H7 from standby mode using the included RTC (Real Time Clock).
5+
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.
6+
Effectivelly, you will get the same effect as with blink.
7+
8+
On the Portenta H7 with the peripherals turned off you can expect around 300uA of current consumption in standby mode.
9+
10+
The example also turns off the peripherals before going to sleep and turns them back on after waking up.
11+
12+
Usage:
13+
- Make sure you are running the latest version of the Renesas Core
14+
- Select the Portenta H7 board from the Tools men
15+
- Select the Portenta H7 USB port from the Tools menu
16+
- Upload the code to your Portenta H7
17+
18+
Original author: C. Dragomir (http://arduino.cc)
3319
*/
3420

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

63+
7764
// The LED should go off when the board goes to sleep
7865
board.setAllPeripheralsPower(false);
7966

0 commit comments

Comments
 (0)