Timer based software reset (with interrupt) after certain amount of time


in my project data gets sends using UART from another main board to the boron. The boron then sends the data to the cloud and sleeps for 5 minutes until it will repeat the process.

from time to time the boron gets stuck in the code and will not go back to sleep and then also the loop is not given.

The normal process from receiving - sending - go to sleep needs about 10-15 sec. so my question is, if it is possible to have a interrupt calling System.Reset() if the particle is 30 sec after the wakeup still turned on.

Doing this will prevent the boron to get stuck in the code when I cant reach it anymore.

Thanks in advanced.

best regards,

Have you tried the watchdog capability ?


1 Like

Thanks @shanevanj, I did not knew this function. I will try it. :slight_smile:

If the power usage when the Sleep fails is a major concern, you might consider changing to Manual Mode.
Here’s the basic Code that seems to work the best for me with Boron’s:

Click Me for Code

int sleepTime =         5 * 60    ;     // (# Minutes * 60 seconds)
int connectionFail =    1 * 60000 ;     // (# Minutes * 60,000 ms ) During the Connection Process, Boron will "Give-Up" after this amount of time and Sleep if un-successful.

inline void softDelay(uint32_t t) {
  for (uint32_t ms = millis(); millis() - ms < t; Particle.process());  //  safer than a delay()

void setup()  {

void loop()   {
  if ( !Particle.connected() ) {

  //  Limit the time spent for the Connection attempt to preserve Battery
  if (waitFor(Particle.connected, connectionFail)) {    // Will continue once connected, or bail-out after "connectionFail" time-limit
    Particle.publish("DeBug", "Boron Awake", PRIVATE, NO_ACK);  // Remove after testing
   //  Perform your Real Publish Here


  // Either the Publish was performed, or the Boron could not connect.  Either way, go to Sleep.

} // End LOOP()

void goToSleep() {
  // Step through the process safely to ensure the lowest Modem Power.    
  System.sleep( {}, {}, (sleepTime) );  // Can also add Pins here in addition to sleepTime


You could also add a Counter when the (waitFor(Particle.connected, connectionFail)) fails, to call System.reset() after a specific number of failed connections.

If your Boron isn’t power-sensitive, then please disreguard.

1 Like