watchDogNotification fix - isOpen delay

MyDoorOpener custom/homebrew "Arduino" backend enhancements sharing and discussions.

watchDogNotification fix - isOpen delay

Postby ToddG » Fri Aug 30, 2013 10:32 am

Another problem I was having was that the isOpen function was reading the pin status so fast that I was getting a false-negative intermittently/every-so-often when the door was open. This would cause the watchDogNotificationsHandler to reset the notificationSent variable resulting in no notification. The simple fix here was to slow things down and add a short delay to the isOpen function.

//----------------------------------------------------------------------------------------------------
boolean isOpen(int pinNumber)
{
#if defined(STATUS_STRATEGY_3VCLOSED_5VOPENED) || defined(STATUS_STRATEGY_5VCLOSED_3VOPENED)
int status = analogRead(pinNumber);
#elif defined(STATUS_STRATEGY_NORMALLY_CLOSED) || defined(STATUS_STRATEGY_NORMALLY_OPENED)
int status = digitalRead(pinNumber+14); // addressing analog pins as digital pins (+14)
#endif

// Added to help with misses on status pin reading. - TSG 8/29/2013
delay(1000);


... I also added a comment for debugging further down in the function.

#if defined(MYDOOROPENER_SERIAL_DEBUGGING)
Serial.print(F("' returning: '"));
Serial.print(retVal ? F("Opened") : F("Closed"));
Serial.println(F("' ***"));
// Added to help with misses on status pin reading. - TSG 8/29/2013
Serial.println(F("Sleeping for 1 second..."));
#endif

return retVal;
}

//----------------------------------------------------------------------------------------------------
ToddG
 
Posts: 6
Joined: Sun Aug 25, 2013 4:34 pm

Return to Arduino Backend Enhancements



cron