I'm trying to do auto-restart for mkr wifi 1010 when it's not connected to wifi for more than 3 mins.
Thank you in advance for any references please tag or share with me.
I'm trying to do auto-restart for mkr wifi 1010 when it's not connected to wifi for more than 3 mins.
Thank you in advance for any references please tag or share with me.
Hi @vamshi43286
The watchdog timer only extends out to 16 seconds, so isn't really suitable for longer durations.
Another option is to perform a software reset in your code using the NVIC_SystemReset() function:
NVIC_SystemReset(); // Perform a system reset
soft-WDT intervals are 8,16,32 Seconds ,1,2,4,8.16 Minutes
Dear MartinL,
Thank you so much for your quick response.
I tried your suggestions, It reset the whole system But I need a restart function(Restart the MKR WIFI 1010 Board).
May Iknow Any restart function is available in NVIC?
Thank you in advance,Thanks for your support.
Dear Juraj,
Thank you so much for your quick response.
I'm using Arduino IDE, Is it work with Arduino IDE Environment.
When I add the library it is throwing an error"Specified folder/zip file does not contain a valid library".
Could you please explain the procedure of how to add the lib and use?
Thank you in advance, Thanks for your support.
Hi @vamshi43286
Please could you explain your understanding of the difference is between a software reset and restart? Since a software reset essentially restarts the SAMD21 microcontroller. Do you mean restarting the board's WiFi module?
If you require different behaviour on start-up based on the type of reset, it's possible to query the SAMD21's Power Manager (PM) RCAUSE register in the setup() portion of your sketch:
Power-On Reset:
if (PM->RCAUSE.bit.POR) { ...
External Reset (board's reset button):
if (PM->RCAUSE.bit.EXT) { ...
Watchdog Timer (WDT) Reset:
if (PM->RCAUSE.bit.WDT) { ...
System Reset (software reset):
if (PM->RCAUSE.bit.SYST) { ...
Dear MartinL,
Thanks for your valuable answer.
I need to write a code when The MKR wifi 1010 board wifi is not connected to wifi for more than 10 secs, I need to restart the board(not by pressing the external RST button) by using code.
This is my code:
#include <WiFiNINA.h>
#define SECRET_SSID "Wifi"
#define SECRET_PASS "12345678"
int status_1 = WL_IDLE_STATUS; // the Wifi radio's status
int status_2;
int counter=0;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
WiFi.end();
}
void loop() {
status_2 = WiFi.status();
//Serial.println("WL_CONNECTED="+String(WL_CONNECTED));
Serial.println("status_1="+String(status_1));
Serial.println("NO_status_2="+String(status_2));
if (status_1 != WL_CONNECTED || status_2 != WL_CONNECTED) {
Serial.print("Searching for the network: ");
Serial.println(SECRET_SSID);
//Connect to WPA/WPA2 network:
status_1 = WiFi.begin(SECRET_SSID, SECRET_PASS);
status_2 = WiFi.status();
Serial.println("counter="+String(counter));
if(counter % 5 == 1){ ///
//restart the board
Serial.println("Press the RST button on the board");
}
counter += 1;
}
else{
Serial.print("connected to the network: ");
Serial.println(SECRET_SSID);
status_2 = WiFi.status();
counter = 0;
//status_1 = WL_IDLE_STATUS;
//Serial.println("YES_status_2="+String(status_2));
}
Serial.println("************************************************************************************************************");
delay(1000);
}
Please look into it the counter logic and give some inputs to do the Software or hardware restart of the board.
Could you please send the example of using the below code
Power-On Reset:
if (PM->RCAUSE.bit.POR) { ...
External Reset (board's reset button):
if (PM->RCAUSE.bit.EXT) { ...
Watchdog Timer (WDT) Reset:
if (PM->RCAUSE.bit.WDT) { ...
System Reset (software reset):
if (PM->RCAUSE.bit.SYST) { ...
Thank you so much for your help.
Hi @vamshi43286
One possibility is to use the Arduino millis() function to determine when three minutes has elapsed, then perform a system (software) reset the board if no WiFi connection is established:
unsigned long previousMillis = 0; // Define previous millis
void setup() {
// Add setup code here ...
previousMillis = millis(); // Set the previous millis
}
void loop() {
unsigned long currentMillis = millis(); // Set the current millis
if (currentMillis - previousMillis >= 180000) // After 3 minutes has elapsed
{
NVIC_SystemReset(); // Perform a system (software) reset
}
}
Dear MartinL,
Thanks for your valuable efforts.
I have tried your Code It's working fine, but I need to run it in a loop
after the software reset.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.