loading

Use a Raspberry Pi and a smartphone (or laptop) to open, close and monitor a garage door. Make opening and closing the door secure by using self-signed certificates installed on family members' mobile phones. If the door is open when it shouldn't be, then send a text message (SMS) to a cell phone.

The goals of this project are to:

  • Make my first instructable - I didn't plan on posting this, but I have received many requests
  • Open a garage door with a standard remote
  • Open a garage door with the wall mounted doorbell garage opener
  • Open a garage door with a SmartPhone
  • Monitor the status of the garage door remotely via a cell phone or laptop (is it open or closed?)
  • Send a text message to my cell phone if the door is open when it should be closed
  • Keep the garage door secure (e.g., on power loss, the door should not open)
  • Do not allow anyone else on the net to open the door (two way self-signed SSL certificate)
  • Use WiFi instead of a wired connection
  • Use a Raspberry Pi

The basis for this Garage Door Opener implementation was derived from the Instructable: Raspberry Pi Garage Door Opener by quartarian. However, I could not order a model A Raspberry Pi used by quartarian. So, instead I used a model B+ Raspberry Pi. The B+ is a newer version and has more USB ports, which simplifies some of the steps.

Changing from an A to a B+ platform caused several changes from quartarian’s original instructions.

Note: Since the original post, I moved this from a B+ to a Raspberry Pi 2 model B. No change in the instructions are required.

I used a MacBook to communicate with the Raspberry Pi, but any computer can be used.

There is no compelling reason to build this device, but it was fun. It is more cost effective to buy one. A similar device can be purchased for about $130 USD.

  • Lift master 828LM
  • Chamberlain MyQ $129
  • GoGo Gate $179
  • Craftsman $100

Notes:

    • Text enclosed in spades, like this ♣replace-this♣ should be replaced with an actual value
    • Arduino underlined blue text is a link. In this case, it is a link to an arduino version of a garage door opener.
    • I’ve attempted to credit every source used. My apologies for any omissions. Most of this document is based on other people’s work.
    • $ indicates a command executed in a terminal window on the MacBook and usually is being executed on the Raspberry Pi

    Step 1: Gather Parts

    Buy or gather parts and tools (prices in USD).

    • Raspberry Pi 2 Model B Element14 $35
    • Panda 300n WiFi Adapter Amazon $16.99
    • 5.2V 2.1A USB Power Adapter from Amazon $5.99
    • Micro USB to USB cable 3ft from Amazon $4.69
    • FTDI TTL-232R-RPI Serial to USB cable from Mouser $15
    • Case from Amazon $6.99
    • SanDisk Ultra 16 GB microSDHC Class 10 with Adapter (SDSQUAN-016G-G4A) from Amazon $8.99
    • SunFounder 2 Channel 5V Relay Shield Module for Arduino UNO 2560 1280 ARM PIC AVR STM32 Raspberry Pi - $6.79
    • 3x Female-Female Jumper Wires. Bought at Fry’s for $4.95.
    • [optional] Dynamic DNS $25 per year for 30 names (dyn.com)
    • 1-Gang 18 cu. in. Old Work Heavy Wall Switch and Outlet Box, $3.12
    • Ultra Pro Single Brush White Wall Plate, $7.88
    • SECO-LARM SM 226L, Garage Door Sensor, price varies widely, $9.99 on Amazon with free shipping
    • 50ft of Solid thermostat wire, Home Depot or Lowe's, ~$20

    My Total: $171.38

    I had the following parts, tools and services:

    • CAT5 Ethernet cable
    • Small gauge wire, 6 ft long
    • Phillips head screwdriver
    • Needle nose pliers
    • Box cutters
    • Jewelers flathead screw driver, needed to loosen screws on relay
    • MacBook (a PC can be used)
    • AT&T U-verse

    Step 2: Setup Raspberry Pi Without Monitor or Keyboard

    All Raspberry Pi projects require some type of setup. I like to use the same set of instructions and, when necessary, have one place to update those instructions.

    Setup Raspberry Pi using the following instructable:

    Setup Raspberry Pi without Monitor or Keyboard

    The instructable above includes optional steps in the appendix. Be sure to do the step:

    Add client-side certs to web servers

    Shutdown Raspberry Pi

    $ sudo shutdown -h 0

    Once shutdown, remove

    • ethernet cable
    • USB serial cable

    These won’t be needed any more. Use wifi, ssh and a terminal window on the Mac Book to run commands on the Raspberry Pi.

    Unplug power and plug power back in, and raspberry pi should reboot.

    Step 3: Install Wiring Pi, Apache and PHP

    Install Wiring Pi

    Open a terminal window on the Mac Book. Login to Raspberry Pi, then download, compile, and install Wiring Pi. This software allows control of the GPIO pins. Here is a step-by-step guide:

    http://wiringpi.com/download-and-install/

    Here is a condensed version of the instructions:

    $ ssh pi@♣raspberry-pi-ip♣
    password: ♣password♣
    
    $ sudo apt-get install git-core
    $ git clone git://git.drogon.net/wiringPi
    $ cd wiringPi
    $ git pull origin
    $ ./build

    Run the gpio command to check the installation:

    $ gpio -v
    gpio version: 2.29
    Copyright (c) 2012-2015 Gordon Henderson
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type: gpio -warranty
    
    Raspberry Pi Details:
      Type: Model 2, Revision: 1.1, Memory: 1024MB, Maker: Sony [OV]
      Device tree is enabled.
      This Raspberry Pi supports user-level GPIO access.
        -> See the man-page for more details
    
    $ gpio readall
     +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
     | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
     +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
     |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
     |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |
     |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
     |   4 |   7 | GPIO. 7 |  OUT | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
     |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
     |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
     |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
     |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 1 | IN   | GPIO. 4 | 4   | 23  |
     |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
     |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
     |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
     |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
     |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
     |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
     |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
     |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
     |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
     |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
     |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
     |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
     +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
     | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
     +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
    

    The above commands should give you some confidence that wiringPi is working OK.

    Install Apache and PHP

    Run the following commands:

    $ cd ..
    $ sudo apt-get update
    $ sudo apt-get install apache2 php5 libapache2-mod-php5

    To verify the web server works, open a browser, and in the URL box enter:

    ♣raspberry-pi-ip♣

    Apache's default website responds with "It Works!"

    Step 4: Website

    Open a terminal window on the Mac Book. Login to Raspberry Pi, then remove the default index.html file, change the permissions on the website directory, and edit a file called index.php.

    $ ssh pi@♣raspberry-pi-ip♣
    password: ♣password♣
    
    $ sudo rm /var/www/index.html
    $ sudo chown pi:root /var/www
    $ sudo nano /var/www/index.php

    And enter the following code:

    <?php 
    	$switch = exec('gpio read 3');
    
    	if(isset($_GET['trigger']) && $_GET['trigger'] == 1) {
    		error_reporting(E_ALL);
    		exec('gpio write 7 0');
    		usleep(1000000);
    		exec('gpio write 7 1');
    		# an accidental page refresh causes the garage door to open
    		# the following two lines must be before any HTML to prevent 
    		# accidental door openings
    		header('Location: /index.php');
    		die();
    	}
    ?>
    <!DOCTYPE html>
    <html>
    	<head>
    		<title>Garage Opener</title>
    		<meta name="apple-mobile-web-app-capable" content="yes">	
    	</head>
    	<body>
    		<table style="width:100%">
    			<tr>
    				<th colspan="4"><a id="HomeAutomation" href="/index.php"><font size="5">Home Automation</font></a></th>
    			</tr>
    		</table>
    		<br>
    		<table border="1" style="width:100%">
    			<tr>
    				<td style="width:25%"><font size="3">Garage Door Opener </font></td>
    				<td style="width:25%"><a href="acrobat_file.pdf"><font size="3">Garage Door Opener Manual</font></a></td>
    <?php
    if ($switch == 1) {
            echo "				<td style=\"width:25%\"><font size=\"3\"> closed 1 </font></td>";
    } else {
            echo "				<td style=\"width:25%\"><font size=\"3\"> open 0 </font></td>";
    }
    ?>
    				<td style="width:25%"><font size="3"> </font></td>
    			</tr>
    		</table>
    		<br><br>
    		<table style="width:100%">
    			<tr>
    <?php
    if ($trigger == 0) {
            echo "				<td colspan=\"4\" align=\"center\"><a href='/index.php?trigger=1'><img src=\"remote-background.jpg\" alt=\"garage remote\" style=\"width:50%\"></a></td>";
    } else {
            echo "				<td colspan=\"4\" align=\"center\"><a href='/index.php/'><img src=\"remote-background.jpg\" alt=\"garage remote\" style=\"width:50%\"></a></td>";
    }
    ?>
    			</tr>
    		</table>
    	</body>
    </html>
    

    CTRL-o and ENTER to write the file, and CTRL-x to exit the editor.

    Change permissions on the file

    $ sudo chmod 664 /var/www/index.php<br>

    Step 5: Website Image

    Grab a high-resolution remote garage door opener from the web. Modify the image as you would like using Mac paintbrush. In the image above, a high resolution Genie Garage Opener was used, a raspberry pi logo was added and the led was removed.

    One image is the background (remote-background.jpg), and the other is the active image (remote-press.jpg).

    The plan was that on button push, instead of blinking the led, the raspberry would blink. I simplified the website.

    Copy the images to the raspberry pi:

    $ scp *.jpg pi@♣raspberry-pi-ip♣:/var/www
    password: ♣password♣

    The web site has a single push button. To verify, open a browser and enter ♣raspberry-pi-ip♣. Instead of Apache's default website, which says "It Works!", the button should appear. Press it.

    Step 6: Remotely Control Webserver

    To make it easy to access the Garage Door Opener from a remote location, I use a dynamic DNS name. Because I don't like remembering IP addresses.

    With this feature, I enter ♣dynamic-hostname♣.getmyip.com in the URL field of a browser. Note: The IP on home routers can change without notice, but this rarely happens. I chose to use DynDNS. You will need to know your router's public IP address.

    U-Verse Router IP: ♣uverse-public-ip♣

    You can view your hostnames and DynDNS Pro account details. Here are a few tips to get started:

    • Create your Dynamic DNS hostname (1 of 30):
      • ♣dynamic-hostname♣
      • Updater Key: ♣dynamic-ip-updater-key♣
    • Install an update client to ensure your hostname is always pointed to the correct IP address.
      • Download and install on MacBook
      • AT&T U-verse IPs rarely change, so the updater above can be run whenever it does change
      • Follow the directions:
        • Add account
        • Enter username and password: ♣dynamic-ip-username♣ ♣dynamic-ip-password♣
        • Select hostname
        • Click Configure Selected Hosts
        • The host should become active
      • Configure your network to allow access to your device from the Internet. You can use our Dyn Wizard for some general instructions on how to do this, use resources such as PortForward.com, or contact the device's manufacturer for assistance.
        • AT&T U-verse
        • Port Forwarding for 2-Wire 3801HGV - this is the AT&T U-Verse router I have. See Updates in an Appendix for how to port forward on AT&T U-verse 5268ac router.
        • Open browser and go to ♣raspberry-pi-ip♣
        • Password: ♣password♣
        • Settings
        • Firewall
          • Choose ♣raspberry-pi-hostname♣
          • Servers
            • Web Server port 80
            • HTTPS Server – port 443
          • Add
        • Save

    Once this is done, the webserver will work from the internet. To verify, enter ♣dynamic-hostname♣ and you should see garage door opener button.

    Step 7: ​Wire the Circuit to the Raspberry Pi

    For the code provided (step 4 and 6), I used GPIO pin 7. It is coincidence that GPIO 7 is the same as wiringPi pin 7. In the PHP code, wiring Pi pin numbers are used and NOT GPIO pin numbers. You can use whichever one you want, but be sure to change the code.

    I tried using twisted wire, but the relay doesn't hold well on twisted wire. Solid wire is better.

    On my first attempt, I created three connecting cables (female-to-male).

    • Use three female to female jumper cables
    • Cut three pieces of solid wire to about 1in.
      • Strip 1/4in on both ends of solid wire.
    • Insert one solid wire into one female jumper cable.

    Here is a better way to create connecting cables (female-to-male):

    • Use only solid wire
    • Cut three 4in pieces of solid wire
    • Strip 1/4in on both ends of solid wire
    • Use female connecting pins
      • Slide one female connecting pin on one end of solid wire and crimp
        • Female pin should not come loose, solder if necessary
      • Slide strain relief over female connecting pin or cover pin with electrician's tape

    Wire the relay to the pi as shown in the diagram:

    • Connect female end of cable to Raspberry Pi pin.
    • Insert solid wire into Relay.

    Step 8: Create a Startup Service

    Most relays including the one purchased, operate like this:

    • When the signal is ON the circuit stays off.
    • When the signal is OFF then the circuit is on.

    If the Raspberry Pi loses power, the relay has a safety mechanism that keeps the circuit OFF.

    A problem could occur when the Rapberry Pi and relay get power restored, but before the Raspberry Pi has finished booting to turn the signal ON which is need to keep the circuit off. You could wake up in the morning with your garage open and potentially a few new friends!

    However, the relay doesn't actually initialize until the GPIO pin mode is set via this command: gpio mode 7 out. Furthermore, if the GPIO pin to ON (gpio write 7 1) before you set the GPIO mode, the relay will stay off once initialized.

    To make this initialization run at boot and don't wake up to new friends, use the following start-up script.

    $ ssh pi@♣raspberry-pi-ip♣ 
    $ sudo nano /etc/init.d/garagerelay

    Then paste this script:

    #! /bin/bash
    # /etc/init.d/garagerelay
    # Carry out specific functions when asked to by the system
    case "$1" in
    start)
    echo "Starting Relay"
    # Turn 7 on which keeps relay off
    /usr/local/bin/gpio write 7 1
    #Start Gpio
    /usr/local/bin/gpio mode 7 out
    ;;
    stop)
    echo "Stopping gpio"
    ;;
    *)
    echo "Usage: /etc/init.d/garagerelay {start|stop}"
    exit 1
    ;;
    esac
    exit 0

    To save: CTRL-o, ENTER

    To exit nano, CTRL-x

    Make the file executable:

    $ sudo chmod +x /etc/init.d/garagerelay

    Now tell your pi to run this script at boot:

    $ sudo update-rc.d -f garagerelay start 4

    (Note: You can safely ignore the "missing LSB tags" warning.)

    Ensure startup script is running

    $ sudo reboot

    Open a browser and click on the opener. The relay should click.

    Step 9: ​Attach Raspberry Pi to the Garage

    When moving the Raspberry Pi, be sure to run:

    $ shutdown -h 0

    You may want to turn off power to the garage. So, the doorbell opener doesn’t electrocute you :). The real reason is each time you short the wires, the door will go up and down.

    Undo the wall screws from the doorbell type opener, which attaches the doorbell to the wall.

    Poke a hole through from the garage behind the doorbell opener to inside the house. In Texas, the Raspberry Pi should not be in the garage, the temperature variation in the garage is out side the Raspberry Pi’s operating specifications.

    Run the relay wires through the hole (use a coat hanger).

    Loosen both screws on the backside of the doorbell opener.

    Strip both ends of the relay wires: 1) about 1/8” inch of the relay side, and about ½” inch on the doorbell side. Bend the doorbell side of the wire into a half loop large enough to fit around the backside screw.

    Connect one relay wire to each screw on the backside of the doorbell, and tighten the screw. The connections are as shown in the image. Since the relay isolates the circuit, the direction doesn't even matter which relay is attached to which screw.

    Step 10: ​Attach Raspberry Pi to SECO-LARM

    Before I had the code finished, my family and I were on vacation and I opened my browser. My browser’s last view was of the garage door opener – the page refreshed and garage door opened. A few days later a neighbor called and asked if the garage door should be open? Luckily, I could close it from 500 miles away.

    This snafu forced me to change the code so this wouldn't happen, and add a sensor and the state of the garage door to the website.

    This is a link to the original instructable for adding a sensor. However, given everything that has already been completed, installing the sensor can be greatly simplified and instead of using python add a couple of lines of code to index.php.

    <?php
    $garageState = exec('gpio read 3'); 
    if ($garageState == 1) {
    	echo "<font size="\"3\"">open</font>";
    } else {
    	echo "closed";		
    }
    ?>
    

    The magnet is attached to the left-hand, top indoor side of the garage door, and the sensor is attached to the garage wall. So, I had to run solid thermostat wire from the sensor back to the raspberry pi. This required a hole from the garage into the attic and from the attic into the wall containing the garage door opener (doorbell switch).

    I inserted a blue junction box between the SECO-LARM sensor and solid wires.

    In my house, there is an 18 inch gap between the ceiling of the first floor and the bottom of the second floor. I assume this is where the heating and cooling ducts run. I needed a drill bit extension long enough to go through the second floor and through the top 2x4 (top plate) containing the doorbell.

    The most important part is when drilling from the attic into the area where the wires will run to the garage door opener is to NOT drill through the electricity. Fixing this was not fun. Seeing the sparks and having the lights go out was pretty thrilling!

    The sensor requires two solid thermostat wires or invisible dog fence wire.

    The Raspberry Pi has multiple pin descriptions (BCM, wPi, physical). The code uses the wiring pi pin numbers. To see all pins, and pin mappings and pin values enter:

    $ gpio readall 

    For a gpio manual, enter:

    $ gpio man

    In the original instructions, Physical pin 9 is ground and connects to one of the SECO-LARM leads. However, this does not work for me. Instead connect the leads to physical pins 15 and 17

    Physical pin 15 (wPi pin 3) goes to 3.3V when the SECO-LARM sensor is closed. Physical pin 17 is 3.3v. If it doesn’t work then switch the connections on the SECO-LARM.

    Attach SECO-LARM to garage door and wall. Run wires and connect to Raspberry Pi.

    Step 11: ​Send Alert If Door Is Open When It Should Be Closed

    If the garage door is open when it shouldn't be, then send a text message to a cell phone.

    Install and configure simple SMTP.

    I have AT&T cellular and use ♣cell-phone-number♣@txt.att.net for text messages. I also have a gmail account, and the example below uses ♣gmail-account♣@gmail.com. If you use different services, then make the appropriate changes.

    For the $ commands below, open a terminal window on the MacBook and login to your Raspberry Pi.

    Ensure repositories are up-to-date:

    $ sudo apt-get update

    Install simple SSMTP and mail utilities:

    $ sudo apt-get install ssmtp
    $ sudo apt-get install mailutils

    Edit the SSMTP configuration file:

    $ sudo nano /etc/ssmtp/ssmtp.conf

    as follows:

    root=♣gmail-account♣@gmail.com
    mailhub=smtp.gmail.com:587
    hostname=♣your-hostname♣
    AuthUser=♣gmail-account♣@gmail.com
    AuthPass=♣gmail-password♣
    UseSTARTTLS=YES

    Edit the SSMTP aliases file:

    $ sudo nano /etc/ssmtp/revaliases

    Create one line for each user that will be able to send emails. For example:

    root:♣gmail-account♣@gmail.com:smtp.gmail.com:587

    Set the permissions of the SSMTP configuration file:

    $ sudo chmod 664 /etc/ssmtp/ssmtp.conf

    The permissions of the file /etc/ssmtp/ssmtp.conf determine who will be able to send emails from the Raspberry Pi. By default this file is owned by the user root and the group of the file is also root.

    Edit the SSMTP aliases file, which contains data about the email accounts:

    $ sudo nano /etc/ssmtp/ssmtp.conf

    Once the above setup and configuration process is complete, test it by sending an email from the command line.

    $ echo "close the garage door" | mail -s "Garage Door Open" ♣cell-phone-number♣@txt.att.net

    Create a script to check if the garage door is open when it shouldn't be, and then send a text message.

    $ sudo nano /usr/local/bin/garage.sh

    and add the following:

    #!/bin/bash
    # check if garage door is open.
    # If open send alert and write to syslog
    up=0;
    door=$(/home/pi/wiringPi/gpio/gpio read 3)
    if [ "$door" -eq "$up" ]
    then
    	logger ♣your-hostname♣: Garage Door Open
    	echo "close the garage door" | mail -s "Garage Door Open" ♣cell-phone-number♣@txt.att.net
    fi
    exit 0

    Then add a crontab to run during the required hours:

    $ sudo crontab –e

    and add:

    # At night, check every hour if garage door is open 
    0 22-23/1 * * * sudo /usr/local/bin/garage.sh 
    0 0-5/1 * * * sudo /usr/local/bin/garage.sh 

    If everything works, then go to the next step.

    Step 12: Put Raspberry Pi in Secret Book

    Put the raspberry pi in a secret book. I got this one at Michael’s for about $7. I cut some small holes for the wires and the power cord.

    Step 13: Appendix: References

    SunFounder 2 Channel 5V Relay Shield Module for Arduino UNO 2560 1280 ARM PIC AVR STM32

    • 5V 2-Channel Relay interface board, and each one needs 15-20mA
    • Driver Current Equipped with high-current relay, AC250V 10A ; DC30V 10A
    • Standard interface that can be controlled directly by microcontroller (Arduino , 8051, AVR, PIC, DSP, ARM, ARM, MSP430, TTL logic)
    • Indication LED's for Relay output status Link to download the document: https://app.box.com/s/tn34l4ub64ndeo1mb0ec

    Step 14: Appendix: Updates

    21FEB2016

    • In the original instructions, there were issues with auto-correct, formatting and clarity of directions.
      • An example issue is when double quotes within code get changed to something that looks like an italicized double quote. However, if you cut-and-paste this into a script it won't work.
      • The instructable editor likes to autocorrect, so wlan turns to plan, and autoremove turns to auto remove. These changes are tough to spot.
      • Some of my directions may not have been clear enough.
      • Normally, I use angle brackets as an indicator for something that needs to be replaced. The editor converts these to html. So, I switched to square brackets, but these can cause problems because they look like code. So, I finally settled on ♣s as the indicator for replacement with an actual value.
    • Over-time I have also improved some of the scripts.
    • Edited Steps 21-26

    03APR2016

    • Created an Appendix with Troubleshooting, References and Updates (steps 27-29)
    • Moved Troubleshooting to Appendix from former step 2
    • Updated and alphabetized the troubleshooting page
    • Changed name of file from test2wifi.sh to garage.sh - just more descriptive.
    • Updated cron to use garage.sh
    • Edited 1, 20-26 (Create a startup service to step before appendix)

    04APR2016

    • Replaced steps 2-11 and 16-20 with my standard was of setting up a Raspberry Pi
    • Updated parts list, step 1
    • Added/merged photos

    05APR2016

    • Simplified website and image (steps 4 and 5)

    01MAY2016

    • Added troubleshooting for Seco-larm/raspberry Pi sensor

    01MAY2016

    • Prior edits not saved properly?

    11NOV2016

    • Updated to AT&T GigaPower and changed the router to 5268ac
    • 5268ac does not support loop back, so Garage Opener server is not accessible from computers on the LAN. For a MacBook to access the garage opener web server do the following:
    $ sudo nano /etc/hosts
    • and add the line
    192.168.1.64    ♣server's-external-domain-name♣
    • Save and exit, CTRL-o, CTRL-x
    $ sudo killall -HUP mDNSResponder
    • The 5268ac's built-in port forwarding rules, such as, HTTPS server, HTTP Server and Web Server do not work. To get port forwarding to work:
      • Open a browser, and go to 192.168.1.254
      • Login
      • Select Settings, Firewall, Applications, pinholes and DMZ.
      • Select the garage opener web server
      • Select User-defined
      • Click a new user-defined application
        • In Application Profile Name enter: PortForwarding
        • In Create Application Definition add each of the following and click Add to List:
          • TCP from 80 to 80, map to host port 443
          • TCP from 443 to 443 map to host port 443
          • UDP from 443 to 443, map to host port 443
          • UDP from 80 to 80, map to host port 443
      • Click back
      • Reselect your web server
      • Select User-defined
      • Add PortForwarding
      • Click Save

    Step 15: Appendix: Troubleshooting

    Disk space used

    Last line shows total disk space used. SD card has 8GB.

    $ cd ../..
    $ sudo du –hx –c

    email

    If you are having issues, then try this:

    $ echo "test" | sendmail -v ♣your-gmail-account♣@gmail.com

    If email is setup correctly, then you should get an email in your gmail account.

    If you get an authentication failure:

    You may need to lower security on your account. However, lowering security is NOT recommended. Google will send an email with a link to lower security setting.

    You can switch from your current email reader to use www.gmail.com to access your account (recommended) or change your settings at https://www.google.com/settings/security/lesssecu... so that your account is no longer protected by modern security standards.

    I do not recommend lowering your security standards.

    If you get an Authorization failure:

    The most probable cause of this is that you have specified a wrong username or password for your gmail account in the /etc/ssmtp/ssmtp.conf file. Double check the values of the AuthUser and AuthPass fields.

    If you get connection lost in the middle of processing:

    Chances are you specified the wrong port for the Google smtp somewhere in /etc/ssmtp/ssmtp.conf or in /etc/ssmtp/revaliases.

    Check the last lines of your logs. There should be some relevant error messages in there:

    $ tail /var/log/mail.log 
    $ tail /var/log/syslog

    Garage Door won’t open

    If everything was working and it just stops, then try restarting. If that doesn't work, pull the power cord from Raspberry Pi, and then restore power. The Raspberry Pi should reboot in less than 2 minutes and everything should work fine. This is generally caused by a loss of power to the Residential Gateway.

    GPIO

    If anything goes wrong, then the best way to see what is happening is with the following command:

    $ gpio readall

    Login to raspberry pi from MacBook

    terminal is a MacBook utility: disk/applications/utilities/terminal. I keep the terminal app in the dock.

    On MacBook, open terminal

    $ ssh pi@♣raspberry-pi-ip♣ 
    ♣password♣

    Login to residential gateway

    On MacBook, open browser

    URL = ♣raspberry-pi-ip♣

    Login: ♣gateway-password♣

    Logs

    If something goes wrong, check these logs for errors, warnings or other issues.

    $ cat /var/log/messages
    $ cat /var/log/syslog
    $ cat /var/log/dmesg

    MAC Directory

    Directory on MacBook where website files are stored

    MAC Directory = /Users/♣my macbook♣/Desktop/wi-fi enabled home/wifi enabled garage door opener/website

    Password

    Password = ♣raspberry-pi-password♣

    RAM and CPU used

    $ top

    CTRL-c to exit

    Raspberry Pi home directory

    $ pwd
    /home/pi

    Raspberry Pi hostname

    $hostname
    hostname = ♣hostname♣

    Raspberry Pi IP

    ♣raspberry-pi-ip♣ = 192.168.1.93

    Raspberry Pi Website Directory

    /var/www

    Seco-larm stops working

    On 01MAY2016, the Seco-larm stopped working. This is the third time the sensor stopped working. To say this correctly, physical pin 15 on the Raspberry Pi stopped detecting the 3.3v input. I tried 3.3v physical pins 1 and 17, and both were still outputting 3.3v. I switched from physical pin 15 to another GPIO, physical pin 16 (GPIO 4) and it started working again. So, there is nothing wrong with the Seco-larm. The problem seems to be with the Raspberry Pi GPIO.

    GPIO 3, physical pin 15 is dead. The is a very good post on how to test GPIO pins.

    I switched from GPIO 3 to GPIO 4, and changed the code accordingly. I am not sure why the GPIO pin stopped working. Here are two possible reasons:

    • I have the Seco-larm sensor mounted so when the door is closed it outputs 3.3v. The garage door is closed more often then it is open. Perhaps, the GPIO pin cannot take a more-or-less constant input of 3.3v.
    • The failure coincided with a power loss, perhaps there was a power spike.

    U-verse Residential Gateway

    I have AT&T U-verse with a Residential Gateway, but any service should work.

    If the U-verse Gateway is restarted or loses power, the Raspberry Pi may need to be rebooted.

    U-verse residential gateway Public IP = ♣router's-public-ip♣

    A U-verse residential gateway's public IP can change, but does so very rarely

    U-verse Residential Gateway Home Page = 192.168.1.254

    U-verse Router wireless access point's SSID = ♣ssid♣

    WiFi throughput is slower than expected

    Change router to a less used channel. By default, all circuit providers tune everyone’s wifi to channel 1. Change to a less used channel, such as, 11. Try to use an odd number.

    Note: I told a couple of neighbors what I did to improve wi-fi and now everyone is on 9 or 11, so I moved back to 1. You should always use an odd channel.

    Open a browser.

    For U-verse, enter 192.168.1.254 in the URL box.

    Click on Wireless link, and pick channel 6 or 11.

    There is an app for smart phone called wifi analyzer. One of the displays shows all the nearby wifi access points broadcasting on a particular channel. In my neighborhood, everyone is set to channel 1.

    Unplug Raspberry Pi, and then restore power

    <p>is this using arduino or just a Pi</p>
    <p>Just raspberry pi.</p>
    first off I'm a certified garage door installer. your idea is a rip off. it's not creative at all. all you need is a opener with myQ. a gateway. and a smart phone. less than 5 minutes to set up and install. that's how it's done..
    <p>Chamberlain announced the release of MyQ on 05NOV2013 in a press release. released http://www.chamberlain.com/chamberlain/media/library/pdf/MyQ-Garage-Press-Release_FINAL.pdf. An early garage door opener was built using an Arduino in 31AUG2009 http://forum.arduino.cc/index.php?topic=7586.0.</p>
    <p>The difference is that your just the guy who plugs them in, he built the device (also using sources from others). So its kinda neat if you already have a PI and dont want to spend $100..</p>
    <p>Wow, that seemed to be a rude comment. Sorry if you feel that one expressing their talent and desire to fully integrate self-generated technology is offensive to you. </p><p>Hope you enjoy installing the myQ product....I ended up giving up on them after my certified garage door installer had to replace 3 of them. </p>
    Sometimes it's not the product, but the process that counts. A knife is fairly simple and reproducible, yet the methods can be quite varied and elegant in their implementation.
    <p>I agree, the idea is not original. I used quartarian's instructable for many of the steps. Technically, MyQ takes a different, perhaps better, approach, </p><p>I tried to cite as many sources as possible. In the instructable, I write it may not be worth building and provide several commercial products, including MyQ. </p><p>My objectives were to: 1) learn how to use raspberry pi and I thought this would be a good learning tool, and 2) build something my family and I would use on a regular basis. Both objectives were met. </p><p>In addition, the garage door opener fits into a larger plan of automating my entire home using wi-fi based devices with no proprietary controllers or gateways. I am almost done integrating my home security system into a raspberry pi. I am sure certified security system installers will hate that one too.</p>
    <p>How do you handle the relays from opening the doors when the pi loses power in a power blip (or randomly shuts down)? Mine works great, but I fear actually using it unless I get a UPS to ensure the PI always has power... otherwise the relay will switch and toggle the doors open! (and yes my pin is initialized at boot via init.d, but this doesnt offer any correction for the door opening in the event of a power blip.)</p>
    <p>Before this project, I only had a &quot;doorbell&quot; button in the garage. If I pushed the button, the circuit closed and the door would open (or close). The relay works in a similar way. When the pi sends the gpio trigger, it is like pushing the doorbell button. The circuit closes and the door goes up or down.</p><p>To send the gpio trigger to the relay, the pi must have power to &quot;close&quot; the circuit. A power blip shouldn't open or close the door. An easy test would be to wire it all up and pull the plug on the pi. Nothing should happen.</p><p>The most annoying thing about a power blip is the pi takes a minute or so to restart and establish wifi communications, and the web app won't open or close the door until it is all working.</p><p>For a long time, I had the pi plugged into a normal wall outlet. During an electrical storm, the house had a power surge and the electricity went off. The pi must have gotten fried. After power was restored, I could never get the board to work again. I replaced the old pi with a new one, and I replaced the wall outlet with a Leviton wall-outlet &amp; surge protector that I got at Home Depot. I also replaced the power supply that came in the kit with a higher performing supply.</p>
    Ohh man! I see what I am doing wrong.<br><br>I have the pi initialize the GPIO to low and send a high to toggle my relay. The problem I had was that if the pi shut down it would default to sen 3v to the relay while off and thus toggle my door.<br><br>I will set it the pin to always be high and use a low to toggle the door instead. So that if my pi ever loses power the door wont open. <br><br>Jeeze I feel so dumb. Thank you
    <p>A very ambitious garage door opener! Thank you for sharing your build with us. I hope we see more from you in the future!</p>

    About This Instructable

    13,202views

    96favorites

    License:

    More by jeff.cartwright.562:Install and Setup Shinken Network Monitor on Raspberry Pi Improve AT&T U-Verse Download Speed from 18Mbps to 22Mbps Accordion Menu  
    Add instructable to: