Introduction: Smart Garage Controller

This project came about when I would leave the house for work and get half way there, only to have a moment of panic set in where I could not remember if I had closed the garage door. Sometimes I was convinced I had not, and turned around, just to confirm I had indeed closed the garage door. Now I get to be 30 min late to work...great. Once I bought my own house, I figured now is when I can do whatever I want to my garage door opener, and this idea was born.


  • Raspberry Pi - I think just about any model should work, as long as it can run Django, NGINX, and gunicorn. I used a Raspberry Pi 3 B+. You may need to change some things if you have a different version. - (
  • microSD card (for
  • 40-pin ribbon cable for GPIO pins - (
  • 4-pin GPIO breakout board - (
  • Opto-Isolated relay board rated for >20v DC - (
  • Perma-Proto half-sized board - (
  • hookup wire (~24-20 AWG) - (
  • Magnetic Reed Switch - (
  • Raspberry Pi HDMI dust cover - (
  • Raspberry Pi Ethernet dust cover - (
  • Raspberry Pi USB dust covers (4) - (
  • Raspberry Pi power source (depending on the model of raspberry pi you are using)
  • Raspberry Pi case - (
  • 3.5 mm jack - (
  • M2.5 screw/standoffs for mounting boards - (
  • 18 AWG cable - (
  • 3mm clear acrylic - (
  • access to laser cutter

Step 1: Assemble RPi

write the microsd card with the latest raspbian image of your choice. ( then assemble the board in the case, and attach the ribbon cable before securing the lid on the case. Then add the dust ports.

Step 2: Cut and Assemble Control Box

You'll need to find a place that will let you cut out your box on a laser cutter, look for a local makerspace or online for places that can cut acrylic. Alternatively, you can probably use any other kind of project box with the proper. Be sure to add a 330 Ohm resistor between 3.3v line and the COM terminal of the reed switch. N.O. terminal goes back to GPIO pin of choice.

Wire the relay with 5v going to DC+, GND to DC-, and GPIO pin of choice to IN.

Garage door opener terminals will go connected to the relay at COM and NO

Step 3: Mount Reed Switches and Run Cable

Make sure your cable does not impede the travel of your door. Wire to the same two screws that your wall buttons connect to to open the door.

Step 4: Connect Your Raspberry Pi to Your Wifi

and make sure you can SSH to your raspberry pi so you can setup the web server. you can then mount it in your garage and the rest can be done from your computer.

Step 5: Install and Configure Software

on the Raspberry Pi, install Django with commands:

  • `sudo apt update`
  • `sudo apt install python3-pip`
  • `sudo pip3 install django`

Then install NGINX and gunicorn

  • `sudo apt install nginx`
  • `sudo pip3 install gunicorn`

Install the python module create a django project, create migrations, and configure

  • copy the tarball to /srv
  • install using `sudo pip3 install django-smart-carhole-0.1.tar.gz`
  • create django project with `sudo django-admin startproject my_smart_garage`
  • `cd my_smart_garage/`

  • edit the file found at /srv/my_smart_garage/my_smart_garage/

  • add the IP address of the raspberry pi or its hostname in ALLOWED_HOSTS

  • add 'door_control', to the INSTALLED_APPS list

  • Edit TIME_ZONE to your time zone

  • Add the following settings to the end of the file: RPI_SENSOR_PIN, RPI_RELAY_PIN, IP_WHITELIST_DOORCONTROL and fill out with it's respective values. See images for examples.

  • Add "path('door_control/', include('door_control.urls'))," to the /srv/my_smart_garage/my_smart_garage/ in the urlpatterns list

  • add ', include' to the import line at the top for django.urls library. See images for examples.

  • migrate the app with 'sudo python3 migrate'

  • test to make sure things work by running the test server with: `python3 runserver`

  • Navigate to your raspberry pi like so: http://[ipaddress]:8000/door_control

  • You should be met with a page like shown.

Now it's time to set it up so the web server runs automatically.

  • First disable debug mode in the file
  • uncomment the server_names_hash_bucket_size 64 in /etc/nginx/nginx.conf
  • copy the gunicorn file to /etc/systemd/system/gunicorn.service
  • copy the nginx file to /etc/nginx/conf.d/smart_carhole.conf
  • start both processes
  • systemctl enable gunicorn.service
  • systemctl start gunicorn.service
  • systemctl enable nginx.service