Instructables
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
1-40 of 75Next »
ctmorrison14 days ago

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.

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.

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.

MidnightMaker (author)  ctmorrison11 days ago

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.

ctmorrison14 days ago

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.

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.

To get Apache up and running:

http://coolestguidesontheplanet.com/get-apache-mys...

Make sure you modify the AllowOverride to "all" if it's not already that. This is required in order for the .htaccess file to be effective.

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

AddType text/cache-manifest .appcache

Here's my reference link for the above:

http://httpd.apache.org/docs/2.0/mod/mod_mime.html...

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 "impgarage" 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.

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.

ctmorrison15 days ago

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!

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.

Thanks!

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.

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

Just FYI. Thanks again.

jbennett381 month ago

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.

I have edited my applicationhost.config file with the following:

<binding protocol="http" bindingInformation="*:57700:" />

I have run the following from an administrator command prompt with "URL reservation successfully added" as a result:

netsh http add urlacl url=http://*:57700/ user=everyone

netsh http add urlacl url=http://+:57700/ user=everyone

netsh http add urlacl url=http://*:57700/GarageImp/miHomeGarage.html user=everyone

netsh http add urlacl url=http://+:57700/GarageImp/miHomeGarage.html user=everyone

I have tried the following in order to ensure the firewall on my Windows 7 box isn't blocking access:

netsh advfirewall firewall add rile name="IISExpressWeb" dir=in protocol=tcp localport 57700 profile=private remoteip=localsubnet action=allow

netsh advfirewall firewall add rile name="IISExpressWeb" dir=in protocol=tcp localport 57700 profile=Domain remoteip=localsubnet action=allow

I'm simply stuck. :( Any help would be greatly appreciated!!

MidnightMaker (author)  jbennett381 month ago

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, http://192.168.1.55:57700/GarageImp/miHomeGarage.html

If this does not work from the local browser, then IIS is configured incorrectly. My <site> key looks like this:

<site name="ImpWebApp" id="228143298">

<application path="/" applicationPool="Clr4IntegratedAppPool">

<virtualDirectory path="/" physicalPath="c:\users\midnight\documents\visual studio 2010\Projects\ImpWebApp\ImpWebApp" />

</application>

<bindings>

<binding protocol="http" bindingInformation="*:50442:" />

</bindings>

</site>

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. http://gilesey.wordpress.com/2013/04/21/allowing-r...

If you are still stuck, I can temporarily host the page for you on my web server.

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:

Web Query Failed [0] responseText =

When I point to my local IP, I just get a 403 error (Service Unavailable).

I'm not sure why this would be (on either case). Any ideas would be greatly appreciated!!

MidnightMaker (author)  jbennett381 month ago

The Web Query Failed message is most likely because the URL for the Imp Agent has not been updated in 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);

You need to put the imp Agent URL code where it says "Your URL Key Here".

Your xmlhttp.open command should end up looking something like

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

where zbgd32jkjw is specific to your imp and can be found at the top of the Electric Imp IDE Agent Window

Capture.PNG
bbiandov4 months ago

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

MidnightMaker (author)  bbiandov4 months ago

Thanks for the info. I will try this out for sure

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?

MidnightMaker (author)  bbiandov4 months ago

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

1. Remove the external switch pullups and use the imp internal pullups - DIGITAL_IN_PULLUP

2. Leave the external pullups and change the pin configuration to DIGITAL_IN

3. Leave the external pullups and leave the pin configuration as DIGITAL_IN_PULLUP

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.

menerso4 months ago

You da man! Awesome device. You should sell on kickstarter.

Thanks for answering my stupid questions.... mine is up and running.

Marty

MidnightMaker (author)  menerso4 months ago

Good job Marty, glad to help... now spread the word!

pricejt445 months 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)  pricejt445 months 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)  pricejt444 months 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)  pricejt445 months ago
Sorry, that should be pin7
aeuderlam4 months ago

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

big hug !

MidnightMaker (author)  aeuderlam4 months 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 !!

nickckingjr4 months 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)  nickckingjr4 months 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.

Louis12465 months 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)  Louis12465 months 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

alexzicong5 months 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?

appgaer6 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)  appgaer6 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-che6 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-che6 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.
RonBrugger8 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)  RonBrugger8 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)  RonBrugger8 months ago
Cheers! That's great!
vroom3509 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)  vroom3509 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.
1-40 of 75Next »