Skip to content

Fix reset pin clashing with Portenta Carriers and Shields #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,23 @@ The procedure:
* `Arduino MKR WiFi 1010`: short the pin 7 to GND until the led turns off
* `Arduino GIGA R1 WiFi`: short the pin 7 to GND until the led turns off
* `Arduino Nano RP2040 Connect`: short the pin 2 to 3.3V until the led turns off
* `Arduino Portenta H7`: short the pin 0 to GND until the led turns off
* `Arduino Portenta C33`: short the pin 0 to GND until the led turns off
* Other boards: short the pin 2 to GND until the led turns off
* `Portenta Machine Control`: currently the reset procedure is not available

### More on the reconfiguration pin
Internally, the pin indicated in the procedure is set as `INPUT_PULLUP` (except for `Arduino Opta` ) and it's attached to an ISR fired on every change of the pin's status.

In order to be notified when the ISR is fired, it's possible to register a callback function using the function `NetworkConfigurator.addReconfigurePinCallback(callback)`. Please take the example as reference.

### Change the reconfiguration pin
In order to change the default pin for resetting the board, it's possible to use the function `NetworkConfigurator.setReconfigurePin(your_pin)` specifying the new pin.
The pin must be in the list of digital pins usable for interrupts. Please refer to the Arduino documentation for more details: https://docs.arduino.cc/language-reference/en/functions/external-interrupts/attachInterrupt/

### Disable the reconfiguration feature
In order to disable the reconfiguration procedure, use this function in the sketch `NetworkConfigurator.setReconfigurePin(DISABLE_PIN)`


## Configurator Agents
The library provides a set of *Configurator Agents* that added as plug-in to the sketch handle the communication between the Arduino Network Configurator and an external client ([*Arduino IoT App*](https://cloud.arduino.cc/iot-remote-app/) and Arduino IoT Cloud) for configuring the board.
Expand Down
3 changes: 3 additions & 0 deletions examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
* - Portenta H7: short the pin 0 to GND until the led turns off
* - Portenta C33: short the pin 0 to GND until the led turns off
* - Portenta Machine Control: the reset is not available
* - Other boards: short the pin 2 to GND until the led turns off
*
* In this sketch the BLE and Serial interfaces are always enabled and ready for accepting
Expand Down
6 changes: 4 additions & 2 deletions src/ANetworkConfigurator_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
#if defined(ARDUINO_PORTENTA_H7_M7)
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
#define ZERO_TOUCH_ENABLED 1
#define PIN_RECONFIGURE 2
#define I2C_ADD_DETECT_MACHINE_CONTROL_1 0x23
#define I2C_ADD_DETECT_MACHINE_CONTROL_2 0x22
#define PIN_RECONFIGURE 0
#define LED_RECONFIGURE LED_BUILTIN
#define BOARD_HAS_RGB
#define GREEN_LED LEDG
Expand Down Expand Up @@ -108,7 +110,7 @@
#if defined(ARDUINO_PORTENTA_C33)
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
#define ZERO_TOUCH_ENABLED 1
#define PIN_RECONFIGURE 2
#define PIN_RECONFIGURE 0
#define LED_RECONFIGURE LEDG
#define BOARD_HAS_RGB
#define GREEN_LED LEDG
Expand Down
3 changes: 3 additions & 0 deletions src/Arduino_NetworkConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() {
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
* - Portenta H7: short the pin 0 to GND until the led turns off
* - Portenta C33: short the pin 0 to GND until the led turns off
* - Portenta Machine Control: the reset is not available
* - Other boards: short the pin 2 to GND until the led turns off
*/

Expand Down
3 changes: 3 additions & 0 deletions src/Arduino_NetworkConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ enum class NetworkConfiguratorStates { ZERO_TOUCH_CONFIG,
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
* - Portenta H7: short the pin 0 to GND until the led turns off
* - Portenta C33: short the pin 0 to GND until the led turns off
* - Portenta Machine Control: the reset is not available
* - Other boards: short the pin 2 to GND until the led turns off
*
*/
Expand Down
29 changes: 28 additions & 1 deletion src/utility/ResetInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@
#include "ResetInput.h"
#include "utility/LEDFeedback.h"

#if defined(ARDUINO_PORTENTA_H7_M7)
#include <Wire.h>


bool isPortentaMachineControlAttached() {
Wire.begin();
Wire.beginTransmission(I2C_ADD_DETECT_MACHINE_CONTROL_1);
if (Wire.endTransmission() != 0) {
return false;
}

Wire.beginTransmission(I2C_ADD_DETECT_MACHINE_CONTROL_2);
if (Wire.endTransmission() != 0) {
return false;
}

Wire.end();
return true;
}

#endif

ResetInput &ResetInput::getInstance() {
static ResetInput instance;
return instance;
Expand All @@ -25,6 +47,12 @@ ResetInput::ResetInput() {
}

void ResetInput::begin() {
#if defined(ARDUINO_PORTENTA_H7_M7)
if(isPortentaMachineControlAttached()) {
return; // Portenta Machine Control is not supported
}
#endif

if(_pin == DISABLE_PIN){
return;
}
Expand All @@ -35,7 +63,6 @@ void ResetInput::begin() {
#endif
pinMode(LED_RECONFIGURE, OUTPUT);
digitalWrite(LED_RECONFIGURE, LED_OFF);

attachInterrupt(digitalPinToInterrupt(_pin),_pressedCallback, CHANGE);
}

Expand Down
Loading