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 bottle.py, 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
so that your system is fully up to date before the installation.
sudo apt update && sudo apt upgrade -y
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 bottle.py 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 install.sh
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:
--snip-- if distance >= YOUR DISTANCE IN CM: #Check if the distance is less than YOUR DISTANCE IN CM return 'The garage is closed.' else: return 'The garage is open.' --snip--
Check out my GitHub repo for all the code, including the install.sh script, python control script, and the android app code. I hope you enjoyed! See y'all next time.