I saw the watchdog/stack post, but the one that I suspect fits my case is this:
Passed pointers going out of scope and becoming invalid may be the reason, or the use of String methods that are "notoirious for fragmenting the heap".
I was doing both by publishing a String... but that's exactly what the following (flawed?) example in the Particle Guide to Webhooks does:
int led = D7; // The on-board LED
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, HIGH); // Turn ON the LED
String temp = String(random(60, 80));
Particle.publish("temp", temp, PRIVATE);
delay(30000); // Wait for 30 seconds
digitalWrite(led, LOW); // Turn OFF the LED
delay(30000); // Wait for 30 seconds
}
I am looking for a clear definition because, though perhaps I've solved my immediate problem by waving an inadequately understood work-around at it, I feel like without a deeper understanding of the problem, it will eventually re-emerge in another guise. I'm oldschool that way.
Update: converting to a global char buffer but continuing to use String methods still ends up crashing to 10 blinks after several hundred successful publications:
#define PARAM_PIN A4
#define PUBLISH_BUFF_SIZE 64 // plenty big
char PublishBuff[PUBLISH_BUFF_SIZE];
double ThisParam = 0;
void setup() {
}
void loop() {
ThisParam = (float)analogRead(PARAM_PIN) / 4095.0;
String(ThisParam).toCharArray(PublishBuff, PUBLISH_BUFF_SIZE);
Particle.publish("Param", PublishBuff, PRIVATE);
}