Introduction: PiGMI

Let me introduce PiGMI - Pi Garage Monitor over the Internet

This is my version of a garage door monitoring system using a Pi. The Pi also controls the opening and closing of the doors and is integrated into HomeBridge so I can say: "Hey Siri, Open Dave's door!".

The project was built in 2016 and has been running ever since. The design was based on keeping things as simple as possible. For example, the garage door has four states: Open, Closed, Jammed, and Obstructed. The first two are obvious, the last two represent if the door is closing and it can't, then it is obstructed. If it's trying to open and fails to do so then it is jammed. The detection of these states once again was kept simple. The door starts to open on about 2 seconds from pressing the manual button, and takes about 15 seconds to close via the manual button ( or the remote control). These two timings were used to detect the jammed and obstructed states. A simple magnetic switch detects the state of the garage door. Again keeping it simple this meant that I did not have to get to involved with the electronics of the garage door. So if the switch state doesn't change after the prescribed time you will get a message . Of course the door could open in time and still jam, but you would notice that - trying to keep it simple! Relays are used across the manual buttons in the garage. It can be configured up to 3 doors.

So the design was to use a Pi to monitor the state of the switch. Provide a web interface for control and allow access via the internet for remote monitoring and control. I reviewed this idea with a friend (Tom Milner) who went off and made the whole web interface for me. You can download the code and try it in demo mode before setting it up on a Pi. The interface allows you to configure the GPIO pins for the magnets and the outputs of the relays. The time delays used in case your door takes more that the default 2 and 15 seconds to move. You create a user and password for security, there is a logging facility. It has the ability to be set up in alarm mode where you can receive an SMS alert if your door is opened while you are away on vacation or just at work. The software has been tested on a Raspberry Pi 3 and Zero. For more information here is a link to the Wiki page My Garage . The monitoring is optional and here is the link.


You will need:

Raspberry Pi ( Pi3 and Zero have been tested) with latest Pi OS on SD card and power supply

Wifi dongle

Magnetic switch(s) ( 1 per door) NO type

Relay(s) ( I per door)

Most electronic parts were sourced from Adafruit or Amazon.

Wire - door bell wire for wiring up the magnets to the Pi

Cases for relays and Pi ( I 3D Printed mine from Thingiverse: Relay , Pi )

My-Garage software

Optional monitoring software

Glue to attach magnet to door and door frame.

Screws for wall mounting cases


Wire strippers,


Staple gun for tacking wire runs in garage.

Wire cutters

Step 1: Setting Up the Pi

There are many tutorials on setting up a Pi so I wont cover them here other than to state what is needed on the Pi.

1) Apache, PHP, Python. Again there are tutorials on these from sites such as Adafruit and of course RaspberryPi Organization.

2) The Pi will need access to your Wifi so that will need to be set up.

3) For access outside of your home you will need to provide a method to get through your router's fire wall. I use a web address from and used a different port number for Apache as an added security feature. Again there are many tutorials on the web for this arrangement.

4) The My-Garage software from Github

Step 2: Wiring and Configuring

Refer to the diagram but they key features are one magnet and one relay per door. For my set up that's six GPIO pins. They are configurable in the software, just make sure you match the right relay with the right magnet on multiple doors! Refer to the image above for the settings page.

Here you can configure the modes ( simulation aka demo mode); The number and names of the doors; The timings for the door opening and closing and the information for sending alarms and monitoring.

The physical wiring again was kept as simple as possible. The output of the relay(s) is jumped across the manual button(s) in the garage. The relay is pulsed for 1 second about as long as it takes you to press the button. The magnetic switch I mounted at eye level on the door track. My doors have a metal track where rollers go. As the software only needs to know if the switch is open or closed you can mount it anywhere that works best for your door. The magnet is mounted on the door (moving part) the switch on the frame. The door operation is not modified inane way. The existing end stops and IR obstruction sensor still work.

Step 3: Testing and Operation

First make sure that your Pi is connected to to your Wifi and the software is loaded. The default operation is Simulation Mode so you can play with the settings. Then make sure your GPIO pins are correctly set in the settings page. This means at some point manually opening and closing the door to check the timings. Mine is set for 3 seconds to open and 15 seconds to close. Set up a user and password and if you installed the monitor code the email and SMS settings. You will have to change line 297 in the monitor code to set up your actual provider for SMS messages. This code is written in Python, but the change is to a text field and so no real coding is needed.

The above images show the "Jammed" and "Obstructed" warnings as well as the open and closed images. You can customize these images yourself and it's documented in the wiki. While the door is physically opening or closing the image changes to an animated GIF file!

Once that is all set up you should be able to use a web page pointed at the Pi to open and close your garage doors. If you set up external access ( pass through your router's firewall) you can monitor your garage doors while away! I added a hook to have Homebridge monitor and control the doors. Setting that up is a different Instructable as you will need to have Homebridge code installed, a plugin and the Monitor code linked up. However, it is nice to have Siri open the garage doors. As an homage to 2001: Space Odyssey, I named the doors Pods. So I can say "Hey Siri! Open the Pod bay doors! " ( See link if you are unfamiliar with the movie. It was 1968!)

Raspberry Pi Contest 2020

Participated in the
Raspberry Pi Contest 2020