Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@reid
Created December 31, 2011 17:37
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save reid/1544666 to your computer and use it in GitHub Desktop.
Save reid/1544666 to your computer and use it in GitHub Desktop.
Garage door opener with Arduino

iPhone Garage Remote

Instead of buying two door remotes, I bought one and control it with my iPhone.

Parts

First, I stole nearly everything from MyDoorOpener.com. Their version uses parts I could not find and requires a $6 iPhone app. Let's improve on that.

Almost everything can be found at RadioShack.

  • Arduino Uno. (RS Cat. No. 276-128, $35)
  • Breadboard. (RS Cat. No. 276-003, $9)
  • SPST, normally-open, 5VDC Reed Relay, rated 0.5A at 125VAC. (RS Cat. No. 275-0232, ~$1)
  • 1K Resistor (RS Cat. No. 271-1321, ~$1)
  • PN2907-type Transistor (RS Cat. No. 276-2023, ~$1)
  • IN4004 Rectifier Diode (RS Cat. No. 276-1103, ~$1)
  • Wires to hook everything up.
  • Clicker Universal Remote Control (optional, or your existing door remote control) (RS Cat. No. 55036741, $30)

Those parts will get you everything you need to open a garage door over USB. You now need to hook this up to a network. The obvious choice is the Arduino Ethernet Shield. However, although RadioShacks in Southern Illinois stock this part, RS stores in Silicon Valley do not stock this part.

I instead will use an Insignia Infocast, a Best Buy version of a Chumby One. I bought a few of these last year for $30 each on clearance.

You could just as well hook the Arduino up to any network-connected computer. I did this for the prototype.

Prototype

The code is crazy simple. On serial data, bring pin 9 low for 1 second.

const int triggerPin = 9;

void setup() {
  Serial.begin(9600);
  pinMode(triggerPin, OUTPUT);
  digitalWrite(triggerPin, HIGH);
  Serial.println("*** Ready.");
}

void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    Serial.println("*** Opening door.");
    digitalWrite(triggerPin, LOW);
    delay(1000);
    digitalWrite(triggerPin, HIGH);
    Serial.println("*** Complete.");
  }
}

Put that bad boy on your Arduino.

Now for the circuit.

  • Transistor base -> 1K resistor -> digital pin 9.
  • Transistor collector -> Arduino GND.
  • Transistor emitter -> relay coil pin 1 (any side).
  • Relay coil pin 2 (other side) -> Arduino 5V.
  • Diode: wire parallel to relay coil, with Arduino 5V on the grey side.

If this is confusing, read MyDoorOpener's assembly instructions which are about the same.

The two output pins of the relay are then wired to your garage door.

Instead of messing with my garage door, I messed with a garage door remote. I opened the Clicker remote and attached the relay to the leads underneath SW1 on the remote's PCB.

Testing

Open Arduino's Serial Console and type a character. The relay will activate.

Quick and dirty web control

Totally insecure, of course.

Create a folder. npm install serialport into it.

door.js:

var fs = require("fs");
var http = require("http");
var SerialPort = require("serialport").SerialPort;

var port = new SerialPort("/dev/tty.usbmodemfd121"); // Replace with your Arduino's location

http.createServer(function (req, res) {
    if (req.url === "/toggle?") {
        console.log("Opening door.");
        port.write("1\r");
    }
    res.writeHead(200, {
        "Content-Type": "text/html"
    });
    res.end(fs.readFileSync("door.html"));
}).listen(1337);

door.html

<!doctype html>
<html>
<head>
<title>Remote Access</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">

<style>
/** Portions Coopyright 2011 Yahoo! Inc.
    http://yuilibrary.com/license/
*/
html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:text-top}sub{vertical-align:text-bottom}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}input,textarea,select{*font-size:100%}legend{color:#000}#yui3-css-stamp.cssreset{display:none}

html {
    background: #000;
}

body {
    font: 100% "Helvetica Neue", Helvetica, sans-serif;
    color: #cfcfcf;
    padding: 15px;
}

h1, input {
    width: 100%;
}

h1 {
    font-size: 350%;
    font-weight: bold;
    letter-spacing: -1px;
    line-height: 87%;
}

h1 b {
    color: #fff;
}

.byline {
    margin-top: 5px;
    font-weight: 100;
    font-size: 170%;
    letter-spacing: 1px;
}

#activate {
    background: #972E1E;
    padding: 50px 20px;
    font-size: 200%;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 7px;
    color: #fff;
    border: 1px solid #EC432A;
}

#activate[disabled] {
    background: #111;
    color: #999;
    border-color: #777;
}

#activate:active {
    background: #DC4129;
} 

#hd, #toggler, #toggler p {
    padding-bottom: 20px;
}

</style>

</head>
<body>

<div id="hd">
<h1>This is <b>Fort Incredible</b></h1>
<p class="byline">Embedded Systems Division</p>
</div>

<form action="toggle" id="toggler">
    <input id="activate" type="submit" value="Activate">
</form>
</body>
</html>

Start and share:

node door.js &
localtunnel 1337
  Port 1337 is now accessible from http://49tz1.localtunnel.com/

To show off, I gave the localtunnel URL to my friends. Success.

If you don't have localtunnel, gem install localtunnel.

Next Steps

  • Chumby hosting the web server, instead of my laptop
  • Putting everything in a case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment