Install script for the Pi Garage Door Opener

November 4, 2020

A few days ago, I was running a full system upgrade on my garage door Pi when it lost power. Anyone who has worked with a Pi, or just SD cards in general, knows what happened next: the card corrupted. For a few days, I put off reinstalling Raspbian because i knew I'd have to manually install, it's dependencies, and the py controller script (which would take like half an hour). Instead, I took about 2 hours writing, testing, and debugging a script which would automate the whole process.


Before running the script, make sure your Pi is wired properly as shown in the video, is connected to wifi, and you can SSH into it over the network. Also, make sure you have run

sudo apt update && sudo apt upgrade -y
so that your system is fully up to date before the installation.

What does it do?

Basically, the script starts with installing python3, python3-dev and python3-rpi.gpio, which are all dependencies of the python script. Then it makes the "garagedoor" directory and changes into it. After this, it fetches from their website. It then fetches the latest version of the python script from the GitHub repo. Finally, it edits the /etc/rc.local file so that the script will automatically run on startup. After this, it waits 5 seconds and reboots.


First, get the latest version of the script from the GitHub repo:


Then, make it executable:

chmod +x

Finally, run the script and follow the terminal prompts:


Once it's finished installing, your Pi will automatically reboot and you'll be able to access it at http://raspberrypi.local:1234/login. The default password is xxxx, which you should change. Also, you can tweak the default sensor distance in the code to match your specific garage door:

if distance >= YOUR DISTANCE IN CM: #Check if the distance is less than YOUR DISTANCE IN CM
    return 'The garage is closed.'
    return 'The garage is open.'

Check out my GitHub repo for all the code, including the script, python control script, and the android app code. I hope you enjoyed! See y'all next time.


Icon Vectors by Vecteezy

© 2020-2021 Ravi Shah