Thanks for the suggestions! I’ll have to think about a permanent NR backup server. Speaking of a watchdog timer, my boiler board reboots occasionally. Perhaps because I have a bug in the following code that has stumped me. Could you take a quick look at the line that says “Why?” Does anything jump out to you, other than being, erm, messy?
I suppose I should post the whole sketch in a new post?
void pub(void) {
// publishes data
long uptime_s = (uptime_ms / 1000);
char uptime_char[12];
//String uptime_string = "";
//uptime_string = String(uptime_s);
static bool oldDigIO[maxDigitalCount];
static float oldTemp[maxTempSensors+1];
bool newDigIO[maxDigitalCount];
static bool firstRun = true;
char temp[7];
static long uptime_s_last = uptime_s;
// send uptime every 15 s
if (uptime_s - uptime_s_last > 15) {
ltoa(uptime_s, uptime_char, 10);
client.publish(will_topic, uptime_char, true);
uptime_s_last = uptime_s;
}
// the following block destroys the value in 'uptime_s' in the above block. Why?
// get digital values
for (int i = 0; i < maxDigitalCount; i++) {
newDigIO[i] = readDIO(digitalAssgn[i]);
// delay(10);
// Serial.println("newDigIO: " + String(newDigIO[i]));
}
newDigIO[5] = statAlarm; // overwrite with the programmatically defined alarm value
// abridged here for brevity
}