Particle publish inside a watchdog call - stack overflow

I’m using the ApplicationWatchdog functionality to trigger a System.reset() in case something goes wrong, and I thought it would be nice to publish a Particle event before restarting so I could get some logging of the event, however whenever the code gets to the Particle.publish line, the light runs through it’s SOS thing with 13 blinks (Stack Overflow). Set up the following code:

ApplicationWatchdog watchdog(10000, watchdogReset);

void loop() {
  while(true) {
    // hang it up!

void watchdogReset() {
  Serial.println("watchdog restart");
  Particle.publish("watchdog restart");


Added the delays just to make sure I narrowed down the problem. Any thoughts on if what I’m trying to do is possible?


Check out

“A default stack_size of 512 is used for the thread. stack_size is an optional parameter. The stack can be made larger or smaller as needed. This is the amount of memory needed to support the thread and function that is called. In practice, on the Photon (v0.5.0) calling the System.reset function requires approx. 170 bytes of memory. If not enough memory is allocated, the application will crash due to a Stack Overflow. The RGB LED will flash a red SOS pattern, followed by 13 blinks.”

1 Like

Derp, sorry for not researching that further (reading all 4 paragraphs of the documentation). Many thanks.