Instructables

Electric Imp Garage Door Opener

FeaturedContest Winner
Picture of Electric Imp Garage Door Opener
DSC05157.JPG
DSC05153.JPG
DSC05135.JPG
DSC05141.JPG
F7.png
WiFiHitchHiker.gif
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.

I finally have a ready made board to support this project available at http://www.mihomeagent.net



 
Remove these adsRemove these ads by Signing Up
bbiandovyesterday

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

pricejt4425 days ago

I am getting a device Error. The index 'pinA' does not exist. Any ideas?
I see in the code where you are referencing hardware.pinA.configure

MidnightMaker (author)  pricejt4420 days ago

Apologies, the code I uploaded has the pin outs for the commercially available board that I sell on http://www.miHomeAgent.net

For the Imp development board, the statement should be hardware.pin7

PinA is not available on the SD card format development devices. I uploaded new code to fix that error.

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

hardware.pin7.write(0);

this still shows as PinA in the new code.

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?

MidnightMaker (author)  pricejt442 days ago

Yes, missed that line too! Sorry!

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 :)

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.

MidnightMaker (author)  pricejt4425 days ago
Sorry, that should be pin7
aeuderlam7 days ago

HY MidnightMaker !! I'm in Brazil, ....amazing your project !!! I go try make ...if I need can call you ?

big hug !

MidnightMaker (author)  aeuderlam6 days ago

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!

very thanks ! I go now buy the kits elétric imp !!

nickckingjr18 days ago

MidnightMaker, thanks for this. It's a perfect solution to maintain my friendship with my neighbor, with whom I share a garage - I have a bad habit of forgetting to close the garage door, which he (understandably) finds infuriating.

I bought the parts on Sunday, bought my first soldering station on Monday, bought a new multimeter on Tuesday, and by 2:00am on Wed morning I had all but the April soldered down. I now consider myself an electronics expert.

I'm hoping to be a programming expert by the end of this week, but I need a little help. I've pasted the Device and Agent codes into the IDE, and figured out the edits to make in the Device section to make the IMP001 work. By jumping the switch circuits, I can get the device log to register open, opening, closed and closing events properly, so I'm on the right track; and I've got an LED and battery set up to test the relay circuit, which I can get to work by jumping the base leg of the transistor to the VIN peg.

I've got a sendhub account set up, but I'm stuck on the internet interface - I've never written code or made a web page, I have no idea what an API key is or where to find it/how to make it...

When I click the "Agent" link in the IDE I get a new tab that says "No data recieved".

Can you tell me if the implementation of 'agents' made steps 6-12 obselete, or do we just skip step 6 and pick up with step 7?

Thanks for your help - NK

MidnightMaker (author)  nickckingjr18 days ago

Hi,

Line 9 is the Api Key that validates the caller (smartphone). This can be any random string you want. It must match the value in the HTML file. So, if you change it in the Agent file - and I strongly suggest you do - copy the exact string to the HTML file. If you look at the code in the HTML file, you will find these lines:

xmlhttp.open("POST", "https://agent.electricimp.com/Your URL Here?timestamp=" + new Date().getTime(), true);

xmlhttp.setRequestHeader("x-apikey", "107ac1217-4cad-2a3b-7630a-b91210227c8da");

You need to put the imp Agent URL where I highlighted in bold above. The API Key is also in bold above. Ignore all references to COSM and the planner in step 6. Step 7 onward is still needed in order to load the HTML to your phone and get the system working.You can test by loading the HTML page into your PC browser, and once it's working there, load the HTML page to your phone.

MM - Still working on this, but I wanted to say thanks for responding. I'm brand new in the computer tech world - basically helpless outside of Windows Explorer and Microsoft Office - but I'm learning. I'll post on the results of my project when I get it wrapped up.

Louis124620 days ago

This looks like a really neat project. An incredible amount of work must have went into it but not knowing how to code I'm having a difficult time. I breadboarded the hardware and the log looks good when I close the open or close switches. The only minor discrepancy I noticed was the schematic called for pins 8 and 9 for the switches and the Device code for pins 1 and 2 which was no big deal. For the Agent could you please tell me what goes on line 9. I put my SendHub API key. Is this correct or should I have left the long character string that was in there? On line 75 I put my SendHub group SMS number and on line 76 I get a error warning in the code when I try to put in my cell phone number and SendHub API key. I also don't know what to do with the html manifest and the cache manifest. I don't understand what instructions I need to follow for the Agent because it looks to me that the write up is mostly for a planner. Also will this code work for an android phone. It looks like it was written for an Apple. I apologize for my lack of understanding but I really would really like to build this.

MidnightMaker (author)  Louis124620 days ago

Thanks for the comments. I inadvertently uploaded the code for my commercial PCB so the pin numbers are wring. But you fixed that :-) so on to the next issue. I have removed the planner code download so that you can only download the new Agent version.

Line 9 is the Api Key that validates the caller (smartphone). This can be any random string you want. It must match the value in the HTML file. So, if you change it - and I suggest you do - copy this string to the HTML file.

What error are you getting for line 76. Most likely you have a missing quote character at the end of the string. You can PM me your code and I'll fix it for you.

"https://api.sendhub.com/v1/messages/?username=919YOURNUM&api_key=Your Key GOes here"

The manifest file just tells the phone what to cache. This means that the phone can run the app without accessing a remote server. There is only one manifest file in the latest uploaded Zip. Just copy the full folder contents to your web server and access the miHomeGarage.html page. The caching will happen automatically on your phone. Then add the web page to your home screen. After that you can shut down the web server.... you only need it to get the html page cached onto your phone the first time.

Feel free to PM me if you need more help

alexzicong1 month ago

hi, im having my final project for my engineering program. I making a doorlock that can be controlled using the imp via wifi. However, I need your help to program my imp similar to yours, but simpler I suppose. i also want to add some extra features. Is there a way to contact you more directly?

appgaer2 months ago

What about authentication?
Isn't it true that if somebody knows what the URL is they can just open and close your garage door?

MidnightMaker (author)  appgaer2 months ago

The connection to the Imp uses TLS for encryption by default. You can add additional header information to uniquely identify http requests to your device. This header information is TLS encrypted. In my case, I have implemented an API Key which gets passed in the HTTPS header. If the API Key does not match, then the request to the IMP URL is rejected. This serves as the authentication mechanism. It also helps not to publicize the Agent URL so that you benefit from obscurity. By caching the App to your phone and not serving it from a publicly accessible web server, you achieve a high level of obscurity - the URL and the API Key is only known to the app on your phone.

Ah-che2 months ago

The problem in this tutorial is that there is no planner any more.. :| Please retype your code for new IDE . Tnx :)

MidnightMaker (author)  Ah-che2 months ago
If you go to step 6 you will find the new code attached there the new code simplifies the architecture by using agents and eliminates dependency on an external web server as well as xively/COSM.

Just cut and past the new code into the agent and device windows of the new IDE. Way easier than working with the planner and much more flexibility on the imp side as a result.

Let me know if you need further help.
RonBrugger4 months ago
Not sure if the code is displaying incorrectly, or what. When I enter the server side code you list above, I get syntax errors in httpwebrequest and string json lines (at least, it only shows the first error it finds and I guessed a fix for the first). I'm also having some difficulty translating your instructions into what I need to do with the new Electric Imp development interface. Any help?
MidnightMaker (author)  RonBrugger4 months ago
The team at Electric Imp will retire the planner on December 17 for good. But they offer a new and improved alternative called Agents which I have now implemented.

I've attached new files that work with the Agent to Step 6 - miHomeGarageAgents.Zip. Cut and past the code into your Agent and Device windows on the Electric Imp IDE:
miHomeGarageAgent.txt for the Agent Code
miHomeGarageDevice.txt for the Device Code

Then you need to edit the HTML file in the new Zip archive and update the URL for your Imp agent. Once you have the garage control working, then you can register with SendHub to get text notification from your device. You will need to edit the Agent code with your specific SendHub key.
Thank you, I now have a completely functional Electric Imp garage door opener/status system. Thanks for your great instructions and follow up.
MidnightMaker (author)  RonBrugger3 months ago
Cheers! That's great!
vroom3505 months ago
Great idea! I always used bluetooth device. That mobile use Electric Imp what kind name App? or browser? that App for Electric Imp only?
MidnightMaker (author)  vroom3505 months ago
Yes, this works for Electric Imp only
All right, I have read through websites about Electric Imp that App what works for them only. I've had experienced advance electronics with bluetooth device, etc I made, but not great far, short distance only, you know.
Electric Imp WiFi for around $30, and Breakout PCB for $13, not bad, I will planning make myself for that and anything, thanks.
MidnightMaker (author)  vroom3505 months ago
Good luck! It is a fun project and it's great knowing the status of your door. No matter who opens your door - you will know about it! Post some pictures when you are done
Osmanli5 months ago
Hi here is my email (sukruckun@hotmail.com) I want to buy a unit for a single garage door. And thank you for your great work.
Dee_Ann5 months ago
Ok, I bought the imp parts but I don’t know where to buy the other things.
Does radio shack sell everything else?
Can I print a parts list, walk into a radio shack and buy the parts in one place?
I thought they just sell cell phones, stereos and toys. I went in one with my son when he was little to but a remote control truck and the sales people were rude and pushy, trying to put the hard sell on me to buy garbage I didn’t want. I was so turned off by them that I swore to never go back again.

Come to think of it, can I simply buy the parts online so I don’t have to go in a store?
I really want to make this thing, I have the most expensive parts to it but that’s as far as I’ve gotten. I don’t even know what to do with the imp thing, I activated it with my iPhone but other than that it seems to be useless. And the imp site, I have ~no clue~ there, I do not understand it at all, not even a little.

Is there a youtube tutorial on how to build this thing? That would be really great.
Thanks.
MidnightMaker (author)  Dee_Ann5 months ago
Hi Dee_Ann, the only instruction for this device is what you see in the instructable. Parts are available at Radioshack. I have not had a negative experience using them (I'm sure this varies by store) - you can order from them online if you prefer not to deal with their shop staff. If you have no electronics hobby experience, this might be a tough challenge. I have just received a batch of PCBs for this project so if you would prefer to buy a complete assembled PCB, you can PM me.
freak27156 months ago
Hey , I like your idea. I notice you told one of the other people on your post that you might be willing to sell them direct. I would need one for 2 separate garage door openers. Could you email me jenglish2715@gmail.com
khuong7 months ago
Sorry novice schematics reader, would you beable to provide more pictures of where all your wires go TO and FROM? Silly request but I'm new and dont want to mess anything up.

Thanks
MidnightMaker (author)  khuong7 months ago
Hello khuong, on the schematic the switch connections are made so that one wire from each of the normally open contacts is connected back to the two pins on the board. You will not harm anything with this connection - it does not matter which switch wire goes to which side of the connector.
The relay must connect to the wires in your garage door controller that connect to the push button switch. There is no polarity to this connection so it does not matter which wire goes to which side of the relay. Your manual for your garage opener will identify the switch inputs for you.

Hope I understood correctly what you are asking. If its still not clear let me know.
lfzguud7 months ago
MUWAHAAAAAA!! It's ALIVE! Finished mine this afternoon - and it works AWESOME!
No more turning around down the road a few miles from home - because NOW we can check it and close it from ANYWHERE!
This is one GREAT instruct able! Thank you!
MidnightMaker (author)  lfzguud7 months ago
Great job lfzguud! It's very gratifying to see an instructable being put into practice. Thanks for the feed back
lfzguud7 months ago
Maybe a silly question... in the picture above it shows that you wired the "open" switch as Normally open (top two contacts as shown). Did you wire the other switch (at the closed position of the door) the same way?
MidnightMaker (author)  lfzguud7 months ago
Yes, wire them both as normally open.

Cheers
MM
Dee_Ann7 months ago
That’s pretty slick how they’ve jacked up the page so that it’s unprintable.
I’ve got a Mac Pro running OS X 10.8.4 and a really, really nice laser printer but the HTML is all jacked up so that the images overlay the text and make printing this page a total waste of time, paper and toner. Thanks bunches Instructables. If that’s how you do business to force people to subscribe then I don’t want to do business with you.
wourmman7 months ago
I've tried to print all 11 steps, not the PDF, on 2 different machines using 3 different browsers, all to no avail -- text is entirely too jumbled. (Wondering if this is Instructables' attempt to make me buy the Pro membership.) Is there another source for the full instruction, or do I need to bite the bullet and print each step independently?

LOVE the concept!
MidnightMaker (author)  wourmman7 months ago
No problem, check your inbox. I sent you something that will help!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!