Keeping Your Garage Secure Using a Raspberry Pi


It is always unfortunate when the garage door is left open when you leave for an extended period of time. This has happened to me a couple of times. By leaving the garage door open, I was inviting unwanted guests into the garage. An unwanted guest can be animals looking for a meal and spreading trash all over. It could also be another person that sees an opened garage door as an invitation to visit. Fortunately, this has not happened to me. It did, however, force me to figure out a solution to notify me when the garage door is opened.

Security Considerations/Requirements

  • A solution must provide me and my wife with a notification when the garage door is in an open state.
  • It must not relinquish control of monitoring to another service.
    • This required the door to be monitored by a device at home and not send data to another server.
  • An on-premise solution required the device to not have any open services.

Raspberry PI to the Rescue

The solution was to configure a Raspberry PI to service my garage door. The configuration required a relay, a magnetic switch, and access to Google’s email API. The relay was used to interface with the garage door. This allowed the Raspberry PI to close/open the garage door. However, to close the door, the Raspberry PI needs to know the current state of the garage door. This is where the magnetic switch was used to determine the state of the door.

When the garage door was in an open state, the Raspberry PI would notify me. This notification repeats every hour until the garage door is in a closed state. To enable notifications, I configured the Raspberry PI to send emails using Google’s Gmail API. Google’s API allowed the Raspberry Pi to send me notifications to alert me of a state change or if the door has been left open. A state change notification is nice if you have a means to shut the garage door. Using the API, the PI can also check for new email and determine if there was a response to a notification. If the garage door is in an open state and there was reply from the correct email address with the correct password, the Raspberry PI would close the garage door.  

Additionally, the notification emails contain images to document the current state of the garage. These images are captured using a camera attached to the Raspberry Pi. So, even If someone opens the garage door with the keypad, it will capture their image.

Not Perfect, but a Start

I have posted the experimental code here. This code has a high chance of containing bugs because it was written to test with my garage door. Some future possibilities for this project could be integrating SMS and other VoIP features. This would allow messages to go directly to the phone without waiting for your phone to pull down email. This would decrease the potential time between the garage door opening and an alert notifying the changed state.

It would be nice to improve some of the security mechanisms. Instead of sending a phrase in plaintext, the project could potentially incorporate rolling passwords and possibly some form of encryption. These mechanisms would ensure the confidentiality of the password. Furthermore, this project does not necessarily need to check an email to close the garage door because it could potentially have a timeout option. If the timer has expired, the garage door would automatically close.



Source link