|
4 | 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 | 5 | This sketch is universal and worksn on both Portenta C33 and H7.
|
6 | 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 through the High Density Connectors and you need a breakout board to access it. |
| 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 | + However setAllPeripheralsPower(false) in this sketch turns off the power lane of the analog pins. |
| 9 | + This means they cannot sink current and therefore cannot be used to wake up the device. |
| 10 | + Hency only D4 and D7 can be used to wake up the device in this configuration. |
| 11 | +
|
| 12 | + On the Portenta H7 only GPIO0 can be used to wake up the board from standby mode. GPIO0 is available through the High Density Connectors and you need a breakout board to access it. |
9 | 13 |
|
10 | 14 | Requirements:
|
11 | 15 | - Arduino Portenta C33, Arduino Portenta H7
|
|
15 | 19 | Usage:
|
16 | 20 | - Connect a button to GOTO_SLEEP_PIN and with a pull-up resistor to 3.3V
|
17 | 21 | - 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/) |
| 22 | + For maximum power saving use external pull-up resistors. |
| 23 | + You will need to power them separately as the 3.3V pin on the board |
| 24 | + is turned off when the device goes to sleep and peripherals are turned off. |
| 25 | + Alternatively, use pinMode(<pin>, INPUT_PULLUP) for the pins and connect the buttons to ground. |
| 26 | + (If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/) |
| 27 | +
|
19 | 28 | - Upload the provided sketch to the board
|
| 29 | + Note: On Portenta H7, you need to upload this sketch to both cores, the M7 and the M4 for it to work. |
| 30 | + You can do so by selecting the M7 core and then the M4 core from the Tools menu in the "Target core" section. |
20 | 31 | - 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 |
| 32 | + - Press the button connected to PORTENTA_C33_WAKEUP_PIN or GPIO0 on Portenta H7 to wake up the board from standby mode |
22 | 33 | - The LED will blink every second to show that the board is awake when not in standby mode
|
23 | 34 |
|
24 | 35 | Original author: C. Dragomir (http://arduino.cc)
|
|
28 | 39 | #include "Arduino_PowerManagement.h"
|
29 | 40 |
|
30 | 41 |
|
31 |
| -#define PORTENTA_C33_WAKEUP_PIN A3 |
| 42 | +#define PORTENTA_C33_WAKEUP_PIN D4 |
32 | 43 | #define GOTO_SLEEP_PIN D0
|
33 | 44 |
|
34 | 45 | volatile bool shouldGoToSleep = false;
|
35 | 46 |
|
36 | 47 | Board board;
|
37 | 48 |
|
38 | 49 | void setup() {
|
| 50 | + // When uploading this sketch to the M4 core, it just goes to standby mode. |
| 51 | + #if defined(ARDUINO_GENERIC_STM32H747_M4) |
| 52 | + board.standByUntilWakeupEvent(); |
| 53 | + return; |
| 54 | + #endif |
| 55 | + |
39 | 56 | pinMode(LED_BUILTIN, OUTPUT);
|
40 | 57 |
|
41 | 58 | // Register the sleep and wake-up pins as inputs
|
|
0 commit comments