Raspberry Pi Zero and Relay for Garage Door Opener

Hello all,

I was in the process of putting together a Raspberry Pi Zero W based Garage door controller. (I already have a Konnected board and love it, but can't afford $80 for just the board) with wired switches for Fully Open/Fully Closed Positions.

I can buy this Pi Zero W with Case and Camera kit for $45.00 USD
https://www.adafruit.com/product/3415

I can add this Relay Board for $12.00 USD
https://www.microcenter.com/product/476352/4_Channel_Relay_Module

I already own some wired switches like these
https://www.amazon.com/Normally-Closed-Magnetic-Switch-Proximity/dp/B076J5TQ7V

I can 3D Print a case for the relays, I already have a bunch of power supplies and all the required cables and memory. I also plan on adding a temperature/humidity sensor to the board as well.

That's around $57 USD for the whole setup. I have additional situations for devices just like this, so I want to make it as modular as possible.

Eventually I will want to put a warning light and buzzer on the additional relays.

My Questions:

What is the easiest way to monitor Pi Based sensors from Hubitat?

Do I need to "pull down" the voltage with a resistor or something on the Door Sensors?

What Python module controls the Relays? Got any example code?

How do I view the camera through a dashboard? Remotely? Can you use the Pi Camera for motion detection and alerting?

I'm not sure if the camera portion is important to you. Based on the OP, I would guess it was more of a side benefit. If it's not part of your primary goal, then you might consider using a nodemcu esp8266 device instead. They are cheap and since you have a 3d printer, you can easily print your own case (tons of blueprints on thingiverse etc). We already have an app with driver's within Hubitat that can handle the communications.

Above is a very active thread with a ton of brilliant minds. @ogiewon or another of our resident microelectronic experts can get you going quickly. I believe this route would be a lot easier and cheaper than trying to use a pi and writing a python integration from scratch.

1 Like

You can run Konnected on your own hardware, for about $12.

The above combination is what Konnected was originally released on. As far as I know, it still runs on this platform, as the MCU is the same. You just need to work out a power supply, a relay, and some wiring.

As @stephack mentioned, you can also do this very easily using my HubDuino software, using the exact same hardware that I have linked above.

For $12, you have a hardware solution with multiple software solutions to choose from. Options are a good thing! :wink:

Update: And here are some less expensive relay modules

2 Likes

I can confirm that the connected firmware still runs on these boards...I use both Hubduino and Konnected on 2 nodemcu boards without issue. Forgot to mention the obvious.

1 Like

If you're looking at using Hubduino and you just want something for your garage door, I would recommend using a Wemos D1 Mini:

With a "realy shield".

This can be powered by a Micro USB power supply and requires less wiring than a separate relay. The Relay board is powered/controlled by header pin connections from one to the other. You can then wire a contact sensor (reed switch) to one of the other pins on the D1.

2 Likes

I've had bad luck trying to get Arduino projects but for the cost I don't think I can go wrong.

Do you think this one will work? https://www.amazon.com/dp/B010N1SPRK

You need a power supply and a relay and breadboard. Look at what @Ryan780 said above. That looks like the most cost effective solution, likely easiest to wire up and use a power supply you probably already have. This might be overkill but it’s what I’ve had success with and still cheap. Just soldered an old 5v power supply to the leads. Works out of the box with Hubduino: LinkSprite 211201004 Link Node R4 Arduino-Compatible Wi-Fi Relay Controller https://www.amazon.com/dp/B01NB0XJ0F

Yes, I use those boards all the time. The advantage of the combo I linked earlier is that the base board offers 5vdc and 3.3vdc pins, can handle a normal barrel connector and can use power supplies in the 9 to 12vdc range since the base board has a 5vc voltage regulator on board. When powering multiple relays, you often need external power. The base board also affords easier GPIO pin accessibility without the need for a breadboard.

It’s really up to you. The combo @Ryan780 posted reduces the amount of wiring significantly, however it probably only allows for a single relay (although I am not sure!)

It does allow for only a single relay. So, if you are controlling more than one garage door, then that's not the best option. The other advantage of the D1 Mini system, if you want a power adapter with a barrel connector....they've got a shield for that!

If you don't mind waiting a month, this one is only $2 and accepts a standard 5.5x2.1 DC barrel connector with anywhere from 7-24v DC. The great part, get yourself some extra long male header pins, solder them to the D1 mini and a set of female header pins on each of the shields and you can make a nice little D1 Mini sandwich. Has MUCH less chance of coming unconnected than header pins. There are a ton of different shields for the D1 Mini system.

2 Likes

Thank you all for your responses. I am investigating and will probably publish what I come up with.

3 Likes

Do you know if any Hubitat app exists that combines relay control + contact/tilt to be a good replacement for MyQ or other garage door "app". I did a quick search but didn't see anything. I've been considering this to get rid of the MyQ/Internet cloud dependency and already have contact switches on my doors to use with the MyQ Lite app.

1 Like

Yes, HubDuino does this, assuming you're willing to build your own solution. This is how I have my pair of garage doors integrated. Within HubDuino, I create a "DoorControl" device, which requires 1 pin for the contact sensor input and 1 ping for the relay output. Within Hubitat, you'll see a single child door control device. It's been working great for me for years now.

2 Likes

I've been reviewing all of the suggestions above. The ones that have built in relays don't seem support sensors. They might but not sure. So I think my best bet for both Garage and sprinkler controller is the "WINGONEER ESP8266 Development Board". I will get a 4 relay board for the garage doors and an 6 or 8 relay board for the sprinklers.

Does anyone know if the board above can only have 6 zones like the Konnected Board?

The ESP8266 has some GPIO limitations. I did some testing and posted a table of my results in my ReadMe. Here is that table that explains those limitations.

Thank you again, I will really have to learn what that means. I knda/sorta have an idea what they mean, but luckily I have an EE who can make sure I know what I am doing.

For your sprinklers, you may want try this board as someone has it working for all 8 channels on HubDuino. There is an example sketch in my repo for it. You will need a USB to UART programmer as well.

Last week I ordered a Wemos Di1 mini with relay shield and door contact to automate my garage door in Hubitat. Is there any other information you can provide specifically to this project to help a noob along? such as pins used, changes to ST_Anything_GarageDoor sketch? etc. I think I have an idea but any guidance would be greatly appreciated.

Since the Wemos D1 Relay Shield probably does not allow you to choose which GPIO pin to use, you will need to determine that on your own and then modify the example Garage Doors ESP8266 sketch accordingly. Also, you’ll need to remove the second Door Control device in the sketch. Make sure you select the correct board in the Arduino IDE’s Boards Manager.

1 Like

Most likely your relay shield will use pin D1 for relay control. All the ones that I have seen use that pin. So, you would have to use a different pin for the contact sensor. I recommend D2 or D5-D7 as there is no interference with boot mode selection.

1 Like

Great thank you all.

Also the existing ST_Anything_GarageDoor sketch appears to be setup using D1 and D2 which is similar to your comment. I will use D1 and D2 and see how I get on. As such I believe the code needs to be changed to reflect.

#define PIN_DOORCONTROL_RELAY_1 D1 //SmartThings Capabilty "Door Control"
#define PIN_DOORCONTROL_CONTACT_1 D2 //SmartThings Capabilty "Door Control"

btw, I assume the D1 will go with the 5v pin for relay and the D2 will go with the 3v for contact correct?

Download the Hubitat app