I've lost count of the number of times we have set off on a trip only to have to turn back to check to see if we remembered to close the garage door. This ‘ible shows you how to connect the Electric Imp to your garage door opener, how to control your garage door from your iPhone and how to check the status of the door from anywhere. Every time the door is opened or closed a sensor is triggered, and a text is sent to a predefined group of phones so that you are always "in the know" as to door status. Commercially available options abound but this solution is easy enough to hack together yourself for small $ outlay.

Even though I’ve used an iPhone for this ‘ible, you could use any smartphone, tablet or other computing device with an Internet connection. As a bonus feature, you can cache the HTML App on your iPhone so that it appears and runs just like a real App Store app, without needing to jump through app distribution hoops or Apple Developer program registration. The smartphone has become an indispensable attachment - most people will never leave home without it, and most people I know can no longer conduct a conversation without checking their phones repeatedly. Tighter integration would require surgery but that is some way out in the future. The net result is that you always have a garage door opener on your person.

The Electric Imp is a fantastic device that enables WiFi control of anything and everything. With a small amount of effort, you can control anything you want with your smartphone, web browser or other Internet enabled device.

To complete this project, we will assemble electronics, write firmware, and develop an HTML App for controlling the garage door. This project interfaces to your existing electric garage door opener via the pushbutton switch that you normally use to open the door. If you have a manual garage door, you are out of luck on the automation side, but will still learn a bit about the Imp, and about creating an HTML App for your phone. After completion of the project, you will be able to use either the pushbutton switch or your smartphone to open the door – all existing garage door opener functionality is maintained.
I do get that opening the garage door from your phone is hardly novel. Someone has most likely cobbled together a steam punk version from scrap parts discovered in a dumpster in some far away country! However, this is my version that answers Imp related questions that appear frequently on forums like “how do I control my imp from a web browser”, or “how do I add a relay to my imp” or “how do I create an html app for my phone?” or “how do I get data from the Imp back to my phone” etc.

Step 1: Operational Secrets

The standard garage door opener button completes a circuit which signals your garage door motor to start opening or closing the door depending on the previous action. If the previous action was to close the door, the next button press will be to open the door and vice versa. The circuitry we add is wired in parallel to the manual pushbutton switch so that either a relay controlled by the circuit or a push of the button will activate the door opener.

With the Electric Imp solution, a tap of the iPhone screen in the Sesame App sends a message via HTTP Post (using either the wireless network or cellphone network) to the Imp Servers with the unique ID of your specific Electric Imp module.

The Imp Server finds the IP address of the Electric Imp being addressed and forwards the message on to your Electric Imp via the internet and wireless router. On the Electric Imp, your Agent code receives the message and forwards it on to your firmware via the "device.send" API function. Finally, your firmware interprets the message according to your functional requirements. In our case, the HTTP message results in closure of the relay contacts connected to PIN 7 of the circuit. Billions of dollars of networking infrastructure are being leveraged to communicate a simple switch contact closure. And it is fast. Occasionally there may be a second or 2 of latency, but for the most part it is pretty quick.

The connectivity is seamless thanks to the magic of the smartphone. When your phone is within WiFi range of your router, you will connect via your router to the Electric Imp Cloud Server, which sends the message on to the Imp through your WiFi router. The message goes from Phone->Router->Imp Server->Router->Imp. When you are out of WiFi range (or turn WiFi on your phone off), the message goes via the cellular network to the Electric Imp Cloud Server, which then sends the message on to the Imp through your WiFI router, or in other words: Phone->Cell Network->Imp Server->Router->Imp.

<p>How do you find the right port to use?</p>
<p>The port is automatically assigned by Visual Studio. If you use the &quot;open in web browser&quot; command from Visual Studio (right click on the html file), you will see the port number in the browser address bar. You can also find the number in the applicationhost.config file.</p>
<p>This project has gotten me back into tinkering, which is a great thing. I've successfully built the unit and am able to see it on my laptop which is running the IIS server. I can see the status of the unit just fine. However, I cannot connect to the page in order to cache it on my phone. I can run a terminal emulator and am able to ping the IP of the machine running IISExpress, but I cannot access the web page via the phone. </p><p>I have edited my applicationhost.config file with the following:</p><p>&lt;binding protocol=&quot;http&quot; bindingInformation=&quot;*:57700:&quot; /&gt;</p><p>I have run the following from an administrator command prompt with &quot;URL reservation successfully added&quot; as a result:</p><p>netsh http add urlacl url=http://*:57700/ user=everyone</p><p>netsh http add urlacl url=http://+:57700/ user=everyone</p><p>netsh http add urlacl url=http://*:57700/GarageImp/miHomeGarage.html user=everyone</p><p>netsh http add urlacl url=http://+:57700/GarageImp/miHomeGarage.html user=everyone</p><p>I have tried the following in order to ensure the firewall on my Windows 7 box isn't blocking access:</p><p>netsh advfirewall firewall add rile name=&quot;IISExpressWeb&quot; dir=in protocol=tcp localport 57700 profile=private remoteip=localsubnet action=allow</p><p>netsh advfirewall firewall add rile name=&quot;IISExpressWeb&quot; dir=in protocol=tcp localport 57700 profile=Domain remoteip=localsubnet action=allow</p><p>I'm simply stuck. :( Any help would be greatly appreciated!!</p>
<p>The easiest way to check to see if IISExpress is set up correctly is to try and open the page from a browser on the host machine using the IP address and not localhost, For example, <a href="" rel="nofollow"></a>GarageImp/miHomeGarage.html</p><p> If this does not work from the local browser, then IIS is configured incorrectly. My &lt;site&gt; key looks like this:</p><p>&lt;site name=&quot;ImpWebApp&quot; id=&quot;228143298&quot;&gt;</p><p> &lt;application path=&quot;/&quot; applicationPool=&quot;Clr4IntegratedAppPool&quot;&gt;</p><p> &lt;virtualDirectory path=&quot;/&quot; physicalPath=&quot;c:\users\midnight\documents\visual studio 2010\Projects\ImpWebApp\ImpWebApp&quot; /&gt;</p><p> &lt;/application&gt;</p><p> &lt;bindings&gt;</p><p> &lt;binding protocol=&quot;http&quot; bindingInformation=&quot;*:50442:&quot; /&gt;</p><p> &lt;/bindings&gt;</p><p> &lt;/site&gt;</p><p>I did a bit of googling and found some useful information here. You appear to have hit most these points but maybe methodically going through this persons suggestions will highlight the problem. <a href="http://gilesey.wordpress.com/2013/04/21/allowing-remote-access-to-your-iis-express-service/" rel="nofollow">http://gilesey.wordpress.com/2013/04/21/allowing-r...</a></p><p>If you are still stuck, I can temporarily host the page for you on my web server.</p>
<p>Could you explain to me what /GarageImp/ stands for in the link below?</p><p><a href="" rel="nofollow"></a>GarageImp/miHomeGarage.html</p>
<p>Garageimp is the web folder that contains your html file. If your html file is in another folder, then you should change the address to </p><p><a href="" rel="nofollow"></a>YourFolder/miHomeGarage.html</p><p>where YourFolder is the folder on your web server that contains miHomeGarage.html.</p><p>You need to edit the html file as described in the comment above this one</p>
<p>Well, in the process of trying to go through the steps once more, I've gone backwards. Now I get the following when I pull up the web app using localhost:</p><p>Web Query Failed [0] responseText =</p><p>When I point to my local IP, I just get a 403 error (Service Unavailable).</p><p>I'm not sure why this would be (on either case). Any ideas would be greatly appreciated!!</p>
<p>The Web Query Failed message is most likely because the URL for the Imp Agent has not been updated in the HTML file. </p><p>If you look at the code in the HTML file, you will find these lines:</p><p>xmlhttp.open(&quot;POST&quot;, &quot;https://<strong>agent.electricimp.com/Your URL Here</strong>?timestamp=&quot; + new Date().getTime(), true);</p><p>You need to put the imp Agent URL code where it says &quot;Your URL Key Here&quot;. </p><p>Your xmlhttp.open command should end up looking something like</p><p>xmlhttp.open(&quot;POST&quot;, &quot;https://<strong style="">agent.electricimp.com/zbgd32jkjw</strong>?timestamp=&quot; + new Date().getTime(), true);</p><p>where <strong style="">zbgd32jkjw </strong>is specific to your imp and can be found at the top of the Electric Imp IDE Agent Window</p>
<p>I am getting the same error but my URL has been changed. What else could be causing the error?</p>
<p>This has been a great project. I just noticed on http://mihomeagent.net that you aren't producing any more. I just wanted to thank you again for providing such a good Instructable! Happy New Year!</p>
<p>The video link seems to be broken.</p>
<p>Thanks for the project, i finished it, now its time to learn about imp.</p>
That's great!
<p>This is what i was looking for! I got everything on a breadboard and using files that you provided, all working fine, im just confused on where is the button to open door? :D or you just click on that robot to open/close the door? Thank you</p>
<p>Correct! Just touch the robot - that sends the signal to the imp agent</p>
<p>Thanks! im gonna start soldering everything up if my kid lets me , hehe</p>
<p> can anyone please share a picture of how you have the &quot;Close Door&quot; switches? Thank you</p>
<p>My garage door rail is a bit different. It has the chain above an inverted T-shaped rail. I piggy backed my bracket onto 2 bolts which were already there. I had to drill 2 holes for the closed door sensor (used the same bracket).</p><p>To mount the IMP, I designed and 3D printed a mount which bolted to the rail above the opener motor.</p>
<p>Here's mine. </p>
<p>I have mine up and running. I haven't installed it in the garage yet, because I want to add the auto-close feature and don't want the garage door operating while I test the code. So far it is a nice neat package. I am planning to 3D print a protective mount for it so that nothing can short out the bottom of the board.</p>
<p>Mine has been running for about a month so far with no issues.</p>
<p>I made some further additions. In addition to twitter, the agent code has access to email and the twilio sms site (not just sendhub). I added the time of the message to the message body so that you could tell when the message was sent in case there was a delay in delivery. To get this right, I had to add the option for the agent to get the timezone offset from TimezoneDB.com. Working great so far.</p>
<p>Looks great!</p>
<p>Thanks! Your Instructable was instrumental in helping me complete mine. If you want, I can send you my code if you want to check out the autoclose feature.</p>
<p>PM'd you my email address. Send me the code and I'll add it to the last step.</p><p>Cheers!</p>
<p>I recently modified the HTML page to include our name at the top -- making it a bit more personal. However, once I did this, I no longer could get it to cache the file. It would not run unless I had the web server running on my MacBook. After a wee bit of research, I discovered there apparently can be an issue with corrupted manifest files on iOS devices. The article recommended turning on/off airplane mode to clear any cached manifest files. This resolved the problem.</p>
<p>I recently made some additions to the code so that it continues in the case that it loses network connectivity. With the example which is downloadable from here, it isn't needed because the IMP does nothing but update status/listen for instructions from the net (which can't be done if there is no net). My version will autoclose the door if it is left open and requires this function to continue even if the network connection is lost. Just something to think about. If anyone is interested in my version of the code, let me know and I can send it to them</p>
<p>I made this instructable many months ago and have been a happy user. I'm getting a notice from SendHub that the free service is ending tomorrow. Has anyone switched to another text service, like the Google service mentioned below? I don't think I can figure out how to switch on my own.</p>
<p>Twiiter instructions are now attached to step 6. Let me know how it goes!</p>
Hey Ron, you can use twitter. I have put together a PDF instruction that should get you going on twitter. Essentially you create a twitter account for your garage door, and then follow that account with your regular twitter account (assuming you have one of course). This requires changes to the imp agent code. I'll post this as well. Give me a couple of hours.
<p>MM and all, I'm up to step 9 - does anybody have any advice for running the HTML app on an android phone?</p>
The app is just an html page so will work on any phone with a web browser. How to cache the app to the phone so that you don't need to access a web server, has only been documented for iOS because that's the phone I have. There may be a similar method of adding the app page to the home screen on android. You could try pinging member lfzguud. He used android phones for the units he built.
<p>I had suggested changing the filename to index.html, but you can't do this unless you also update the appcache file the same. I changed the filename back to the original and no longer got errors in my browser.</p><p>I did have some issues getting the most recent version down to the iPhone and I believe this was due to sloppiness on my part with the manifest file revision number.</p><p>I'm now try to ascertain what all needs done for a 2 door application. Looks fairly straight forward as long as I get the HTML div's set up correctly.</p>
<p>Hi ctmorrison, if you need code for a dual door solution, I can email it to you. Just send me a PM with your email address. </p>
<p>This really is a super project and I'm very appreciative of @midnightmaker for taking the time to help us all benefit from his experience.</p><p>One of the issues I struggled with is how to do this on a Mac running Mavericks. As you Mac-heads might know, Apple chose to disable the personal web server in Mavericks. Fear not, it's easy to get it up and running. Through quite a bit of web browsing, I was able to get enough info to offer some guidance on getting the iPhone files ready to be served so the app could be installed via my Mac. Rather than regurgitate, I'm going to offer a few web links that I believe will get you through this.</p><p>To get Apache up and running:</p><p><a href="http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-9-mavericks/" rel="nofollow">http://coolestguidesontheplanet.com/get-apache-mys...</a></p><p>Make sure you modify the AllowOverride to &quot;all&quot; if it's not already that. This is required in order for the .htaccess file to be effective.</p><p>You will want to edit the .htaccess file located at /Library/WebServer/Documents/.htaccess and include the MIME file type with the following command at the top (use Nano in a terminal window in a similar fashion to what is described in the above link):</p><p>AddType text/cache-manifest .appcache</p><p>Here's my reference link for the above: </p><p><a href="http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addtype" rel="nofollow">http://httpd.apache.org/docs/2.0/mod/mod_mime.html...</a></p><p>I wanted to make files available in my Sites (User/tom/Sites) folder to be served, so I also created a tom.conf file in the /etc/apaches/users folder as described in the coolest guides site. This is purely optional. In either case, you'll want to create something like the suggested &quot;impgarage&quot; folder in the location of choice and put the downloaded files there, renaming the html file to index.html to make getting to it a bit easier.</p><p>I believe that's it. I gave it and try and was pleased it all worked. In the spirit of instructables, I thought I'd pass along what I learned for others who may have been facing the same frustrations as I was.</p>
<p>Nice project! I've been thinking of doing this, but would likely use GroveStreams as a place to log open/close requests and events. It can also be used to send SMS (fees may apply) or email (free) status updates. Your project has me re-inspired!</p><p>I did notice the device code seems to be a cross between imp001 and imp002 devices, based upon what pins are referenced. Any chance of cleaning this up? Don't mean this as a complaint, but thought you'd want to be aware of what I noticed. I'm assuming it's due to the original device being an imp001 and then your revision being based upon an imp002.</p><p>Thanks!</p>
<p>Well done project! I purchased an ElectricImp after seeing your project. However, I'm planning to add a feature which needs some additional inputs. I thought I would post it here in case it's of interest to anybody.</p><p>I want the garage door to automatically close after 20 minutes if left open. I also want to add an override switch inside the garage which would disable this feature (for when you're working in the garage/driveway). I want this auto close feature to work regardless of how the door was opened (even if opened using the real remote opener).</p><p>Just FYI. Thanks again.</p>
<p>On the 100 TXT limit issue at sendhub: Google Voice now has java API and their TXT is still unlimited and free: https://code.google.com/p/google-voice-java/wiki/GettingStarted</p>
<p>Thanks for the info. I will try this out for sure</p>
<p>I hope I'm not crowding out the discussion; I noticed that the Imp has configurable internal pull ups and you do configure those in your code using configure(DIGITAL_IN_PULLUP, checkSensorStates); However you also use external hard-wired pull ups. The internal ones pull to 3.3v and the external once pull to 5v though via a 56k resistor. Wouldn't that create a strange voltage devider across the Imp's internal 3.3v regulator and your 56k resistor?</p>
<p>You are right - this will affect the overall resistance of the pull-up. 56K in parallel with the imps roughly 10K results in about 8k4 pullup. Not a concern at all, but certainly redundant. You have choices</p><p>1. Remove the external switch pullups and use the imp internal pullups - DIGITAL_IN_PULLUP</p><p>2. Leave the external pullups and change the pin configuration to DIGITAL_IN</p><p>3. Leave the external pullups and leave the pin configuration as DIGITAL_IN_PULLUP</p><p>I recommend removing the external pullups and using the imps internal pullups as the most cost effective solution i.e. option 1. I changed the code when I stopped using external pullups on the commercial board. Thanks for pointing this out.</p>
<p>You da man! Awesome device. You should sell on kickstarter.</p><p>Thanks for answering my stupid questions.... mine is up and running.</p><p>Marty</p>
<p>Good job Marty, glad to help... now spread the word!</p>
<p>I am getting a device Error. The index 'pinA' does not exist. Any ideas?<br>I see in the code where you are referencing hardware.pinA.configure</p>
<p>Apologies, the code I uploaded has the pin outs for the commercially available board that I sell on <a href="http://www.miHomeAgent.net" rel="nofollow"> http://www.miHomeAgent.net</a></p><p>For the Imp development board, the statement should be hardware.pin7</p><p>PinA is not available on the SD card format development devices. I uploaded new code to fix that error.</p>
<p>No problem, I did just compare your new code to the old. Looks like you missed one other line. // Make sure pin is low - relay off</p><p>hardware.pin7.write(0);<br><br>this still shows as PinA in the new code. <br><br>I still haven't figured it all out. I shorted my switch inputs to trick it into thinking my door was open. I am still always getting a return of partial open. Any ideas? </p>
<p>Yes, missed that line too! Sorry!</p><p>You must short one switch and leave the other open. If you short both switches, the door is open and closed at the same time :)</p><p>If both are open, it assumes the door is between open and closed - or partially open. Check with a multimeter to see what the line state is going into the imp. It should be about 3.3V when the switch is open, and zero when the switch is closed.</p>
Sorry, that should be pin7
<p>HY MidnightMaker !! I'm in Brazil, ....amazing your project !!! I go try make ...if I need can call you ?</p><p>big hug !</p>
<p>The best way to contact me is to send me a message through the instructables Personal Messaging system. I'll help you get it done!</p>

About This Instructable


982 favorites


More by MidnightMaker: Cafe Racer Gas Tank Bluetooth Thermometer CNC Padded Jewelry Boxes
Add instructable to: