Introduction: Garage Genie - Parking & Remote Control

The Garage Genie is a car automation Arduino gadget. Click on the two images above to see the animated explanation. It aims to do a few things:

1. The “traffic lights” tells you when you’ve inched your car up close enough when parking. The lights are control by an Arduino using an ultrasonic distance sensor.

2. The ultrasonic distance sensor tells the system whether a car is parked in the stall or not. Using iPhone or Android app, you can check whether or not someone’s car is in the garage.

3. Non-invasive remote open/close operation of the garage door via smart phone app. I'm using a spare garage door remote so that you don't need to cut into existing wiring.

4. Webcam view of garage if you have a webcam in the garage.

5. Notification when car arrives, either via email or audible announcement

The Garage Genie is part of my series of Instructables for Arduino devices based on an awesome, open source home automation platform called OpenHAB.


Here is how the pieces of the Garage Genie fit together. Continue on for a step-by-step of how it's built.



Don't know if it'll amount to anything. But I'm in the Instructables Contest, if you want to vote. Thanks!

Step 1: Parts List and Initial Hardware Prep

Here's the parts list.

  1. Ultrasonic distance sensor (less than $4)
  2. Arduino Uno clone ($9)
  3. Arduino prototype shield ($4)
  4. Arduino ethernet shield ($8)
  5. Relay module ($6)
  6. Color LEDs
  7. Dupont cables
  8. 5V AC adapter (like from a smart phone / USB charger)

The initial hardware preparation involves putting the Arduino together and getting the garage door remote ready for wiring. I've combined these tasks into this step.

Once you have the parts, assemble the Arduino components (Arduino, ethernet shield, prototype shield) into a stack like this. Pretty simple.



Next, we'll be using the relay module to actuate the button on the spare garage door remote. To do this, we need to prepare the remote. First, remove the circuit board and solder wires to one of the buttons. This following series of pictures should give you a good idea of what to do.


Here's the circuit board removed from the remote housing.


Next, decide which button corresponds to the garage door open button. Use a multimeter to determine which two pads/legs on the button are shorted when the button is pressed. Solder a few inches of wire to these two legs. You should take the batteries out of the remote so you don't accidentally operate the garage door.


If you measure the continuity across the two wires, it should be an open circuit. Once the wires are installed, try to open garage by touching the two wires together. It won't work because the batteries aren't installed. Put in the battery and try again.

Ok, next!

Step 2: Software Setup

The data flow diagram above explains how the three pieces of software (Arduino, Mosquitto, and OpenHAB) work together to get the functionality we're after. This one diagram pretty much explains how all the communications work. Hopefully it makes sense.

Let's take care of the PC side by installing the two programs Mosquitto and OpenHAB.


Mosquitto

Install the MQTT broker called Mosquitto. Once installed, Mosquitto can simply be ran by double clicking on the executable after installation. Make sure Mosquitto is running by navigating to the program folder and running this following command in the command prompt window ("dos prompt").

cd C:\"Program Files (x86)"\mosquitto
mosquitto_sub -h localhost -t #


This subscribes to all topics on the MQTT broker. When numbers come in from the Arduino's ultrasonic distance sensor in later steps, you'll see them appear here. And when you push the garage door open button, you'll also see that activity here. Use ctrl_c to cancel out of this.

OpenHAB

OpenHAB is the main server. It can be installed on a PC, Mac, or Raspberry Pi (and other similar single board computer). The Raspberry Pi is ideal for this since it's very energy efficient, but for first time users, a Windows or Mac installation will be easiest.

Install OpenHAB according to the instructions on the OpenHAB wiki. Get familiar with some of the OpenHAB files like the sitemap, item, and rules file. The wiki does a good job explaining this, so I'll forgo the OpenHAB explanation myself.

Once installed, use the attached text file and add the appropriate sections to the configuration of the item, sitemap, and rules files. Here's the the graphics used for the "car present" indicator, but you're free to use your own if you're artistically incline. The images go in \webapps\images of the OpenHAB folder.

https://www.instructables.com/files/deriv/F0E/GPI7/...

https://www.instructables.com/files/deriv/FOD/7LGJ/...

https://www.instructables.com/files/deriv/F3X/4R03/...

That should be it for OpenHAB. If you're using Windows, double click the "start.bat" file in the OpenHAB folder to start running it. Open a browser and go to "http://localhost:8080/openhab.app?sitemap=demo" to view the interface.

For the mobile app, download it from the app store and enter the IP address of the PC hosting OpenHAB. You'll have to "port forward" and create a "dynamic DNS" in order to use the app outside of your home wifi network. I won't go over this detail, but google it and you shall find.

Step 3: Parking Lights Circuit

Next, assemble the circuit for the LED lights. The resistor values can be anything from 150 ohms to 220 ohms, depending on how hard you want to drive the LED's.

Step 4: Non-Invasive Remote Garage Door Control

Next, wire up the relay circuit as shown above. You should already have the circuit board for the remote garage door opener ready. The two wires from the remote control just needs to be wired into the first relay's normally open terminal.

I don't recommend powering the relay coils using the Arduino. You should use a separate power supply, like a 5V USB charger. I used a spare one I had laying around. They're so common you likely have one you're not using. Cut off the ends, solder dupont cables to them so you can simply connect them to the male JD-Vcc pin on the relay. Connect the common wire from the AC adapter to the GND on the Arduino, as shown in the wiring diagram.

Step 5: Upload the Arduino Code

At this point, you may want to take the battery out of the remote again so that you can test communications without needlessly operating the garage door.

Upload the following Arduino code. Check out the header comments to determine what edits are required. You'll need to change the IP address of the server. You may also want to edit the color ranges for the LED's. You can use the serial monitor to see whether or not the Arduino is connecting to the MQTT server, and what the distance sensor is seeing. There are lots of println statements in the code for troubleshooting.

Step 6: Webcam View

You can use any webcam that has a mjpeg stream and that you can access on LAN without password. Edit the OpenHAB sitemap file and change the IP to the IP address of your webcam.


Frame label="Camera" {
Video url="http://192.168.1.71:88" encoding="mjpeg"
//Video url="http://204.248.124.202/mjpg/video.mjpg?camera=1" encoding="mjpeg"
}//end frame "camera"

I happen to be using a USB webcam connected to a small Linux computer, running a program called Motion. I won't prescribe what webcam to use, since there's so much variety. If you're running the server on a Pi, you can put this Pi in the garage and run Motion and a USB webcam off of it.

Step 7: Automation

Now, you might be asking - "what's the use of the car presence indicator if there is already a webcam view?"

Good question! First, I like making tutorials that can be used by people in different circumstances. And some people don't have a webcam in the garage. So they would be using the presence indicator.

But, the more interesting thing for having a digital bit represent "car present" status is that now you can do automation! A simple example is to set up OpenHAB to email you when someone's car arrives in the garage, and announce that person's arrival.

rule "send email when arrive"
	when
		Item itm_garage_dist changed from CLOSED to OPEN
	then
		say("Mom is home")
		sendMail("youremail@gmail.com", "mom is home" , "just now")
end


The speaker on the computer will perform a text-to-voice action and announce "mom is home". Then it sends an email. If you have fancy Sonos speakers (which I don't), OpenHAB can control those speakers to start playing music when you come home.

If you want an idea of how the text-to-speech sounds like, take a look at this video for my laundry room automation.

Step 8: Remote Access, Security, and Tips

Since this is opening a garage door, you'll want to make sure you authenticate and encrypt the communication between the mobile app and your server. This is pretty easy to do with OpenHAB. First, create a user and password on the server. Under ~/OpenHAB/configurations/users.cfg, add a user and password like this:

user1=password1
user2=password2


Once that's done, you need to be able to access OpenHAB via the encrypted port 8443. Test this out first by going through your web browser and going to

https://192.168.x.x:8443/openhab.app?sitemap=demo

If that works, you'll have to setup a port forward in your router to access the server at port 8443. To make it easier, setup up dynamic DNS so you don't have to remember your home IP address, which might change.

This project is purposely made to work with a hard ethernet connection so no wireless gateways are needed. If you don't have ethernet to your garage, it's pretty easy to make a wireless bridge using a cheap $20 "tomato" or "dd-wrt" compatible router.

Step 9: Conclusion & Video Demo

This video demo goes over all aspects of the Garage Genie.



OpenHAB has been around for a couple of years now, but it's mostly been used by people who are automating commercial products like Sonos speakers or Phillips Hue lights. There hasn't been a lot of information on how to use Arduino with OpenHAB. It's odd considering there's so much potential for Arduino users to integrate their custom Arduino gadgets to OpenHAB.


This Garage Genie project originally started out as a request from commenters on my other Uber Home Automation Instructable. The Uber project focused on wireless Arduino sensors, but a lot of people wanted a more simple wired setup. This project is a good complement because it shows how to use OpenHAB with a wired Arduino for inputs and outputs. The code is easily adaptable for whatever sensor and output you might need. For example, you can add a PIR sensor to the garage Arduino and have it act as a security device; turn on a light, play a loud audio file, and send an email notification if an intruder is detected.


Once you have the infrastructure in place, the possibilities are endless!

Comments

author
wilgubeast made it!(author)2014-10-24

So cool! I'm happy to see that you've responded to commenters from your other automation project. The fact that this project is so adaptable for other sensors and outputs makes it all the better.

author
electronichamsters made it!(author)2014-10-24

Hey, thanks. Yeah, this stuff is really exciting. The more people get into it, the more cool, creative stuff we'll get to see. Love internet of things.

author
dsutherland made it!(author)2016-09-03

Hi electronichamsters,

I have built this and the LED's change colour OK and the door button in openhab operates the relay but my icon does not change in openhab to show if the car is in the stall or not..

I get this in the serial log from arduino when moving in front of the ultrasonic sensor ...

starting MQTT send
MQTT connected OK from MQTT Send
4122
4123
4124
finished MQTT send

Have renamed the icons you uploaded to mycarstall-OFF and mycarstall-ON

Only the mycarstall-OFF icon shows at all times.

Please tell me where I have gone wrong

author
rfmdelgado made it!(author)2016-04-01

great instructable, I wonder you can give me some hints on connecting tonmqqt broker when arduino is outside the LAN. I connect but no success with publish our subscribe.

author
JeanN6 made it!(author)2016-02-17

Hello, please I have the code for arduino for this particular project..thanks

author
ragothaman.ramanujam made it!(author)2015-11-03

Hi, I am 69 years old trying this nice project. Now my mobile app to openhab link is OK and arduino serial port also shows the MQTT is connected, but no data exchange takes place. I am not sure about openhab.cgf file and mosquitto.conf file, can some one share these two configuration files, please.

author
SkynetHome made it!(author)2015-06-13

For anyone who may be going through the nightmare that I did trying to make this work with a different 5V Relay and no LED's or Ultrasonic Sensor here is what I did to make the program work.

I attached an W5100 Ethernet Board generic to the Arduino Uno R3 and the 5V Relay I bought has Two Relays on it and is configured with an Optoisolator which caused me major problems in wiring up the relay based on the instructions here.

What finally worked is supply 5v power and ground to VCC and GND on the 4 pin connections labeled VCC - IN1 - IN2 -GND

LEAVE THE JUMPER ON the two VCC pins on the isolator

Connect the Ethernet shield to the relay board at IN1 from Digital Pin 9

Change Sketch to identify pin 9 as the garage button pin

(Pin 4 is used by the ethernet board to control SD card slot)

Once this was done everything worked out perfectly!

Thank you very much for this instructable. I am looking forward to configuring it to work with a presence rule so that it will be trigger automatically on arrival and departure from home!

author
JobJ made it!(author)2015-06-05

When I run the command, i get an Error Message:

mosquitto_sub.exe - Ordinal Not Found.
The Ordinal 285 could not be located in the dynamic link library SSLEAY32.dll

I installed OpenHab and mosquitto on My Win 7 PC.

Any help is highly appreciated.

Capture.PNG
author
apzeiro made it!(author)2015-02-02

Hi friend. First I have to say that I loved your projects. I woul like to know if its possible to use more than one Arduino to send/receive instructions in the network? Thank you.

author
matthew.denecke made it!(author)2015-01-19

​So I found the issue.. just dont know how to fix it. I ended up installing a java app called mqtt-spy https://code.google.com/p/mqtt-spy/

I connected to my server them under topic i entered 4132 and pressed publish and the relay went off. So my issue is with OpenHab. I copied and pasted your coding right into so I am kind of confused.

I am going to keep messing around with it. Any ideas would be nice.

Thanks.

author
kart-racer made it!(author)2015-01-22

In the mosquitto.conf file did you remove the # in from of the port 1883 ?

# Default listener

# =========================================================

# IP address/hostname to bind the default listener to. If not

# given, the default listener will not be bound to a specific

# address and so will be accessible to all network interfaces.

# bind_address ip-address/host name

bind_address 192.168.0.50

# Port to use for the default listener.

port 1883

author
matthew.denecke made it!(author)2015-01-23

I kind of feel stupid... lol.. I forgot to add the mqtt java files to openhab.
I have it working now and it is awesome!

author
kart-racer made it!(author)2015-01-23

Thats great you got it working. I am still waiting for parts from China, tracking says they are now in Chicago so I should have them soon.

author
BertramKaufmann made it!(author)2015-01-18

Nice project, have you also an example how to configure mosquitto for the communication with OpenHub ?

You make a realy good job, thanks

Bert

author
matthew.denecke made it!(author)2015-01-17

Thats my problem I think. When press the door button on the website the relay does not activate. I know the relay works because when I power on the relay the door opens. See the commit I just post that enplane more. I am at a total lost right now.

author
matthew.denecke made it!(author)2015-01-03

Hi has anyone tried using the internal garage door opener instead of
the remote opener? I am thinking about this project... While waiting on
part from China :(

author
kart-racer made it!(author)2015-01-17

I am going to hook one up to my garage door opener, but I too am waiting for parts from China.

author
matthew.denecke made it!(author)2015-01-17

I got my parts last week and setup everything. To me everything it talking correctly but when I press the open button on OpenHab the relay does not click. I dont have it connect to the door opener but still thought it would make a clicking noise. Maybe I have it setup correctly but i dont know.

author
electronichamsters made it!(author)2015-01-17

Use a volt meter where the relay output is. Before concluding it's the relay, make sure your Arduino really is turning on the output.

author
matthew.denecke made it!(author)2015-01-17

I hocked up the relay to the wire for the button to open the boor. It only works when I power of the replay. I think there is a issue with OpenHab. I am using the command mosquitto_sub -h localhost -t # to watch communication from the Arduino and I get

hello world
43.0
88.0
0000

Also openhab is connection to masquitto I see it in the logs.

Just when I press the door button on the webpage it seams like the command is not working even though I see below in the logs.

2015-01-17 18:31:36.259 [INFO ] [runtime.busevents ] - itm_park_gara
ge_btn received command OFF
2015-01-17 18:31:36.264 [INFO ] [runtime.busevents ] - itm_park_door
_mqtt_act received command OFF

author
kart-racer made it!(author)2015-01-17

If you put an ohm meter across the relay contacts that will go to the garage door, you should get a brief short when you activate the relay.

author
Oliverhall made it!(author)2014-11-19

I like your project! Very educative ;)

A lot of the parts needed for this project can be purchased for cheap on this webstore:

http://voltatek.com/en/

author
camblonie made it!(author)2014-11-02

I've got all the parts now so I have a couple more questions.

Are the car icon files really supposed to be named something normal? Save-as from above makes them into a really funky name. Can you point me to the logic that chooses which icon to display?

Basic question on the network, does the .cfg file need to be modified to subscribe to MQTT in general or is this just handled item by item? I assume the password is not required for this to work.

Thanks, Scott

author
electronichamsters made it!(author)2014-11-02

1. OpenHAB is using the icon in the /images folder. The name of the icon it's expecting is defined in the item definition for itm_park_car_present in the greater and less than sign. It's looking for that name appended with "-ON" or "-OFF". I didn't realize OpenHAB changes the file names. I'll fix that later.

2. The .cfg file's MQTT section is edited so OpenHAB knows the IP address of the MQTT broker. The specific MQTT topic name is defined in the individual item definition in the .item file.

3. Mosquitto is setup to not use password by default.

author
camblonie made it!(author)2014-11-09

I assume we set the MQTT transport in the config file the same as the wireless project. After doing that I still don't think OpenHAB is communicating with Mosquitto. I confirmed Mosquitto is subscribe/publish working but if I subscribe to 4132 per the example above I cannot see a command for the door relay through the broker. Is the below normal?

Launching the openHAB runtime...
osgi> 02:06:29.322 INFO o.o.c.internal.CoreActivator[:61] - openHAB runtime has been started (v1.5.1).
02:06:50.020 INFO o.o.i.t.mqtt.MqttService[:106] - MQTT Service initialization completed.
02:06:50.029 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mymosquitto'

author
electronichamsters made it!(author)2014-11-10

It seems like OpenHAB is connecting to Mosquitto OK. Only thing I can think of is something is wrong with the item definition, and you're not really subscribing to the topic you think you are? When you force publish MQTT topics, do you see the OpenHAB shell report these items? Also try refreshing your browser?

author
camblonie made it!(author)2014-11-12

Thanks for sticking with me Eric. For some reason I had a hand full of bindings in the addons folder but apparently not the ones I needed. Did you try Abouillot's RFM on RPi yet? My 3.3v uno is due any day and I don't want to jack up my RPi now.

author
iam_maker_leo made it!(author)2014-11-10

Great!!!

I want to copy this project. hahaha!!

Thank you for your sharing....

- Korean engineer

author
Honus made it!(author)2014-10-24

Very cool project!

author
Sparkynerd made it!(author)2014-11-09

I get an error opening the .ino file. This is the first portion:

"Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0

at processing.app.Sketch.setCurrentCode(Sketch.java:1182)

at processing.app.Sketch.load(Sketch.java:220)

at processing.app.Sketch.<init>(Sketch.java:142)

at"

What am I missing?

author
Sobibobi made it!(author)2014-11-02

Any chance to get your private email to communicate offline? Would like to discuss with you on a project I would to hire someone to speed up things

author
Sobibobi made it!(author)2014-10-31

Hi, the links for the openhab part returns empty, any chance to update them ?

author
electronichamsters made it!(author)2014-11-01

Seems to work for me. Temporary glitch perhaps?

author
thebeswick made it!(author)2014-10-30

Great project. Nice intro to Openhab. I've been playing with MQTT on Arduino and Piface for a while, this project really helped me put the pieces together. Thanks

author
electronichamsters made it!(author)2014-10-30

I know what you mean. So much of this type of automation is about finding the right tools to piece together. A lot of stuff I've seen required writing your own website...that's great if you're good at it, but you have to take care of security and authentication, and OpenHAB does all of that and SO MUCH MORE - it can control Sonos speakers and z-wave stuff and all kinds of things. It's a much more polished setup. I haven't even begin to scratch the surface. Hope to dig into it more.

author
mwils made it!(author)2014-10-28

Great project but I'm curious why you are putting the relay closure across the switch on the remote instead of going directly to the closure input on the garage door opener itself.

author
electronichamsters made it!(author)2014-10-30

For flexibility, I used a relay closure across a remote instead of the hard-wired wall opener. Some newer garage door systems have a circuit board on the wall-mounted opener because the wall opener also controls lights and displays back-up battery status on the wall-mounted unit. There's some kind of comm protocol for that unit, it's not a simple open/close circuit. And you don't have to re-run that pair of wires.

Also, some people might just want to utilize the opener portion of this tutorial. They could put the relay and Arduino inside the house next to their router.

author
zzbb made it!(author)2014-10-27

Nice!
Do you have a brand name for that garage door? Trying to decide what type of door to use on new garage and never seem one like that before. Thanks

author
electronichamsters made it!(author)2014-10-27

Well, I have a Sears brand garage door opener. I used a Chamberlain garage door remote. But it doesn't matter what kind of garage door you have, just the remote. All the garage door remotes I've ever used worked the same way - make contact closure with a button. So this method should be pretty universal.

author
zzbb made it!(author)2014-10-28

My question was about the garage door, since as stated -- NEVER SEEN one like that before. Thought others might be curious as well.

author
espdp2 made it!(author)2014-10-27

Great project! Now go find some lube for that clanky garage door. :-)

author
Sonicblaze made it!(author)2014-10-26

I'd suggest you look into UL325; a good read up is here: http://suretycam.com/control-your-garage-door-remotely/

Basically to remotely control a garage door opener without being present, it's recommended (and required by law in Nevada) to meet these requirements. The primary ones being a safety device to ensure no one is under the door (laser sensors that most doors already have), but you also must have audible and visual warning for 5 seconds before the door activates

author
BrianHanifin made it!(author)2014-10-26

Am I missing something. Don't garage door openers handle sensing obstructions on their own?

author
Sonicblaze made it!(author)2014-10-26

Most of the newer ones do, using the photoelectric beams mounted about shin high.

However there's two additional requirements to meet UL325, which is 5 seconds of audible/visible warning before the door closes. I was just suggesting the additions of that, shouldn't be too hard with the arduino to make some beeping sounds through a speaker and flash some bright white LED's or something. I've wanted to make this for myself, and this is an awesome instructable, so I might figure that part out myself if I get time :-)

author
electronichamsters made it!(author)2014-10-26

Thanks for the pointer about the new regulation. I think this highlights the strength of Arduino solutions. Where as the commercial solution takes years to come up with, Arduino users just need to add three lines of code and utilize another of the relays on the 4 channel relay and add a buzzer. Love Arduinos.

digitalWrite(buzzerPin, LOW); //active low

delay(5000);

digitalWrite(buzzerPin, HIGH);

//rest of remote switch code

author
Ninjarooster made it!(author)2014-10-24

Woah! Nice!! ...if only I had a garage.... XD

author
camblonie made it!(author)2014-10-24

Great stuff. Keep it up.

author
SparkySolar made it!(author)2014-10-24

Thank you for your nice instructable.

Rima

About This Instructable

79,219views

802favorites

License:

Bio: I love home automation. I hate home automation.
More by electronichamsters:Gingerbread Home AutomationTweeting Pregnancy TestPhysical Home Automation Interface
Add instructable to: