Pete, Thank you for taking the time to create, post and explain this. I've been struggling with an optimized battery powered sensor and this nailed it. Personally, I broke new ground on multiple fronts with this one. First foray with 2.2 and first custom boot loaders.
Question:
-
My objective is to create a standardized set of sketches for battery powered motion and door/window switches. I'm looking for that instant gratification of a light turning on the moment presence is detected. Yet, battery optimization is still important.
-
How do you recommend I remove some of your bouncing goodness in this sketch for my purposes?
-
I experimented with the following, but my knowledge of 2.2 and interrupt challenges is limited. My attempt was to reduce the sensor state checks from 3 to 1, but I failed at that. I assume it might be better to change the approach, but didn't want to start hacking your code goodness with my lack of 2.2 knowledge.
#define DEBOUNCE_DELAY 1001 // reduced to 1001. Appear to be no issues, but the impact is minimal
uint8_t oldContactVal = 1; //changed from 2 to 1. Caused failure, but I changed this combo of 3 variables at the same time. I'm not sure which one or if all together cause the failure. I'm still slow on arduino / mysensors logic.
uint8_t contactVal[1]; //changed from 2 to 1
uint8_t contactTracker = 0; //did not change. I left this at zero
int8_t wakeVal = 0; //did not change. I left this at zero
else {
//Woke by interrupt, send contact value
if (contactTracker < 1) { // I changed this for <2 to <1
Any insights from the community are appreciated.