I'm using something like this and getting more reboots than I should. I suspect something is not ok about using wdt disable/enable cycles like this.
Can anyone give me some advice on it?
void loop() {
wdt_enable(WDTO_8S);
if(pinChangeInterruptFlag) { // we can get interrupted any time, but mostly just 8 second sleeps and wakes
do_small_stuff() //takes a couple of seconds
if (extraStuffNeeded ){ //happens sometimes. uh oh, this might take 6 seconds...
wdt_disable(); // so lets give ourselves another 8
wdt_enable(WDTO_8S);
go_do_extra stuff();
}
}
wdt_disable();
radio.sleep();
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}
Thanks,
Jerry