# Rpi3 GPIO Garage Door Opener Example

**URL:** <https://community.openhab.org/t/rpi3-gpio-garage-door-opener-example/61316>\
**Category:** Tutorials & Examples\
**Tags:** gpio, garage, rpi3\
**Created:** [December 27, 2018, 6:19pm UTC](https://community.openhab.org/t/rpi3-gpio-garage-door-opener-example/61316 "2018-12-27T18:19:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![openhab2](https://community.openhab.org/letter_avatar_proxy/v4/letter/o/ec9cab/32.png) [@openhab2](https://community.openhab.org/u/openhab2)\
**Post date:** [December 27, 2018, 6:19pm UTC](https://community.openhab.org/t/rpi3-gpio-garage-door-opener-example/61316/1 "2018-12-27T18:19:52Z")

</div>

I am using a raspberry pi3b GPIO pins to control a relay board which simulates someone pressing the garage door opener on the wall. i tapped into the buttons on the wall and ran a pair of wires to the relayboard and connected them to common and normally open.

This tutorial assumes you have the GPIO binding installed and have already gotten that working for other items.

My config settings.

**Items**

```csv
Switch GPIO_GARAGE_DR_EAST "Garage Door (East)" { gpio="pin:13 force:yes activelow:yes initialValue:high" }
Switch GPIO_GARAGE_DR_WEST "Garage Door (West)" { gpio="pin:6 force:yes activelow:yes initialValue:high" }

```

**Sitemap**

```php
    Frame label="Garage Doors" {
        Text item=GARAGEDOORS {
            Frame label="Garage Door Control" {
                Switch item=GPIO_GARAGE_DR_EAST
                Switch item=GPIO_GARAGE_DR_WEST
            }
        }
    }   

```

**Rules**  
The rule here performs a momentary connection of the wires (1/2 second) which is required by my garage door opener to activate a press.

```php
rule "pulse garage door East"
    when   
            Item GPIO_GARAGE_DR_EAST received command ON
    then   
            Thread::sleep(500)
            GPIO_GARAGE_DR_EAST.sendCommand(OFF)
    end

rule "pulse garage door West"
    when   
            Item GPIO_GARAGE_DR_WEST received command ON
    then   
            Thread::sleep(500)
            GPIO_GARAGE_DR_WEST.sendCommand(OFF)
    end

```

Later, I plan to add some contacts to the garage door to know the position. A camera would be great too once I can figure out the right hardware etc.

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [December 27, 2018, 6:32pm UTC](https://community.openhab.org/t/rpi3-gpio-garage-door-opener-example/61316/2 "2018-12-27T18:32:43Z")

</div>

Nice tutorial, 👍 thanks for contributing to the forum.

> [@openhab2](#):
>
> Later, I plan to add some contacts to the garage door to know the position

If you want more info, like how far the door is open, you may want to look at a rotary encoder.😉

> [@openhab2](#):
>
> A camera would be great too once I can figure out the right hardware etc.

Raspberry makes a camera, not sure about the quality but worth a look.

I have a motion sensor setup in my garage that works well and its cheap.😉  
Here’s a link if your interested.

> [@Microwave Radar Motion Sensor](https://community.openhab.org/t/microwave-radar-motion-sensor/51456):
>
> Thought I would write a review on the RCWL-0516 for anyone interested in a microwave motion sensor. Today marks the 4th week of my testing with this sensor and I have found that it is very reliable. The sensor only detects larger objects that contain water e.g. human body, large animal, milk jug filled up and thrown.laughing No false triggers from birds, trees blowing in the wind, etc… Range of detection is 15 to 30 feet (5 to 9 meters) that can be adjusted using a resistor. The RCWL can also …

---

<div class="post-metadata">

**Author:** ![openhab2](https://community.openhab.org/letter_avatar_proxy/v4/letter/o/ec9cab/32.png) [@openhab2](https://community.openhab.org/u/openhab2)\
**Post date:** [December 27, 2018, 7:22pm UTC](https://community.openhab.org/t/rpi3-gpio-garage-door-opener-example/61316/3 "2018-12-27T19:22:45Z")

</div>

> [@H102](#):
>
> If you want more info, like how far the door is open, you may want to look at a rotary encoder.😉

very interesting… I’ll have to check that out. I was planning to tie into my alarm as a separate zone so that i could read it that way (open/closed), but i like that idea. Right now I am playing with my Sonoff S20 and just flashed Tasmota. going to configure my mqtt broker and give that a whirl. Lots to do!

I am looking for an IP camera, i think that would work best for me.

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [December 27, 2018, 7:27pm UTC](https://community.openhab.org/t/rpi3-gpio-garage-door-opener-example/61316/4 "2018-12-27T19:27:44Z")

</div>

> [@openhab2](#):
>
> very interesting… I’ll have to check that out. I was planning to tie into my alarm as a separate zone so that i could read it that way (open/closed), but i like that idea.

I mentioned it b/c sometimes we leave the garage door cracked open and it’s good to know when it’s only cracked or wide open.

> [@openhab2](#):
>
> I am looking for an IP camera, i think that would work best for me.

See this binding to get a list of cameras that work well with OH.

> [@IpCamera: New IP Camera Binding](https://community.openhab.org/t/ipcamera-new-ip-camera-binding/42771):
>
> This binding is now merged into openHAB 2.5.9 and newer. See below for more details on what each brand of camera has working as often choosing the right camera will save you from needing to purchase an extra video server (both the cost to purchase the server, plus the ongoing electricity costs) to process the video feeds. Features for Generic cameras with only RTSP (no snapshot url): Snapshots (jpg) can be created from RTSP with low CPU overhead but requires non stop network traffic to keep a…
