more G-Labs products

Author Topic: Garage Door controller using Raspberry Pi Zero  (Read 4558 times)

December 14, 2015, 03:33:08 PM
Read 4558 times

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
Ok HG community I need some more help!

I was one of the lucky few to get my hands on one of the new RPi Zeros. It really is as small as it looks.

I've got Raspbian Jessie running on it. It's not the fastest bit of kit but it's so cheap!

So it got me thinking. I currently have a Wemo device that I can open and close my garage door with but I want something a bit more reliable as Wifi is a bit hit and miss in the garage where the Wemo device is and I also want to know when the door is open or closed so I need to get some sensor information back as well. Step in the very cheap RPi Zero.

I run HG on a desktop PC.

So how do I do this? My current concept is that the RPi will act as an intelligent sensor and door controller (i.e. it will open or close the door). Control for this will come from HG on the desktop so that I can continue to use HG from my mobile device to open or close the door.

I've looked through the forums and its really unclear to me how I can get this to work as I think that most post assume that you have HG running on the RPi?

So I have some magnetic door sensors that I have managed to hook up to the RPi with bell wire and can detect the change in status (yes, programming in RPi is also new to me and I am not a programmer but like a lot of non-programmers on the forum I can dabble enough to get most t
things working with a bit of help, I like to push my boundaries!). I'm using Python 3 on the RPi to be able to use the Pi Zero library to control the GPIOs (very confusing to have the library named the same as the new device!). I'll also use the GPIO pins to activate the door mechanism.

Oh and I want to send a message to one or mobile phones to notify when the doors are opened or closed for peace of mind.

So what's my best approach? Has someone already done this within an HG environment that I could copy from? Any helpful suggestions would be greatly appreciated.

Cheers,

Roger

December 14, 2015, 11:59:39 PM
Reply #1

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
I've tried installing HG onto the RPi Zero as an experiment just to see if it was usable. It's painful to the point of not being so.

December 15, 2015, 01:03:23 AM
Reply #2

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
I suggest trying openhab or domoticz as a better alternative :)
Anyway this sounds very strange since I'm running hg on a very old rpi with no issues, so you might be doing   something wrong. First thing I would suggest is using debian wheezy.

Cheers,
g.

December 15, 2015, 08:20:42 AM
Reply #3

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53

December 15, 2015, 03:18:37 PM
Reply #4

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
should be usable as the CPU is the same as the older ones and I am using them without too many issues.

Again try wheezy and disable any unused programs or add-ons and don't bother running a gui :)

I would use a GPIO on the pi and use the event forwarding via MQTT. - Just configure it to forward status events etc to your desktop, trigger the sensors on the zero and they will appear on the desktop.

You may want to think about where you run program code too, either on the desktop or on the zero :)

Only thing is I would be very careful when using the GPIO's as you need to think about initial pin states and whether anything could inadvertently trigger it :)

Would be worth making sure you have a reed switch on it, or a rotary encoder or similar if a roller shutter so that you can determine the position.

I am that paranoid with mine, I have the alarm control it.. Once my alarm (proper alarm, not software) is armed it toggles an output which turns OFF a relay (rather than turns on!) this relay then interrupts power to my garage door, so it can't be re-opened accidently.

My paranoia for this comes from I cannot see my garage door from my house.. I look at the back of it and its right on the edge of the pavement :)

December 15, 2015, 03:20:46 PM
Reply #5

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
Just had a thought that if you use an i2c IC such as the MCP23017 then your unlikely to get spurious i2C messages and unlikely for software upgrades to toggle GPIO lines :)

December 15, 2015, 04:09:40 PM
Reply #6

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
Thanks for the responses David.

Some of what you have suggested is new to me being a non-techy type, so here come the newbie questions, rather a lot of them I am afraid!

Let's start with the Debian installation.

I assume that Raspbian Wheezy is what I need or should I be installing something else? Regarding the "unused programmes", how do I identify these and remove them? Also regarding the GUI, are you implying that there is a command line interface to HG? I've not looked for it yet, but is there some documentation on it to get me started that you can point me at?

OK, MQTT next.

This is new to me. I've quickly googled it to work out what you meant. In concept that seems a good idea to me, anything to take load off the RPi Zero seems the way forward from what I have seen. I assume that I would run the MQTT broker on the PC, subscribe to it in some way from HG and publish sensor information to it from the RPi. How would I handle the reverse route when I need to instruct the RPi to close the door through one of the GPIO pins? Through the same routes but with subscription from RPi and some sort of push from HG when a "switch" is toggled in the dashboard? Apologies for the language, I am sure I have abused terms all over the place! BTW I assume this would negate the need to run HG on the RPi? Any recommendations on the MQTT broker for the PC that I should be using?

BTW I get your notion of paranoia for the doors to open randomly, fortunately I can see the doors from the house and we are in a fairly good spot anyway, but I will build some sort of check in as belt and braces.

Finally, i2c IC - what are you on about?!!! I really couldn't get my head around that from a quick google. Just couldn't relate what I was reading, which was quite technical, to this scenario... sorry probably being a bit thick.

Cheers,

Roger

December 15, 2015, 04:13:04 PM
Reply #7

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I know the RPi Zero is cheap, but it may not be the best tool for this.  I don't have one to experiment with, but the way I see it, you have a device that has I/O and a decent CPU but no network included.  It seems to me that you could get an Arduino with network adapter and do MQTT too.  The Arduino uses way less power and gets right to the core of what you are trying to do rather than messing with Linux.  I see advantages to the RPi, but I think I would probably opt for the Arduino approach.

December 15, 2015, 04:43:52 PM
Reply #8

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
Agree with the above, I was just assuming it was a pi with a usb network adapter..

Quote
assume that Raspbian Wheezy is what I need or should I be installing something else? Regarding the "unused programmes", how do I identify these and remove them? Also regarding the GUI, are you implying that there is a command line interface to HG? I've not looked for it yet, but is there some documentation on it to get me started that you can point me at?


Correct.

I would update Mono and install homegenie on the Zero.

Quote
Unused programs


I was talking about unused within homegenie.. I don't see the point in running stuff that I am not using  I would rather see all this disabled by default personally :)

Quote
MQTT
Dont worry about it.. homegenie will cover that unless you want to do MQTT between different properties :)

Just follow this: http://www.homegenie.it/docs/interconnecting.php

think of i2c as a protocol that (multiple) specific IC's can use to talk to each other in a common connection type..

You give them an address and then send commands.

you could use something  like this http://www.rapidonline.com/electronic-components/ciseco-k002-slice-of-pi-o-break-out-board-kit-with-mcp23017-for-raspberry-pi-73-4594 if your not doing your own boards..

coupled with these make relay control nice and easy:

http://www.ebay.co.uk/itm/5V-DC-Relay-Modules-1-2-4-and-8-way-Opto-Isolation-arduino-pic-pi-avr-NewUK-/190950013824?var=&hash=item2c7581fb80:m:mh7-znFR8bJkYR0gNXsV8XA

If link doesn't work just search on ebay for arduino 8 way relay (They are available in 1 - 8 way and opto isolated)

As for the GUI i was more on about x windows.

David

December 15, 2015, 04:46:10 PM
Reply #9

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
Edit to above:

If your not bothered about whether the outputs could be inadvertently triggered then you could skip the i2c and drive the relay board direct from the gpio's - work well.. I use them to control my security lights, mounted in metal clad single gang enclosures with £4 Ebay External 12v PIR's.. connected to GPIO's.

December 15, 2015, 05:46:43 PM
Reply #10

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
David, thanks for clarifying. Hopefully I'll get some time tonight to have another go!

December 15, 2015, 06:07:27 PM
Reply #11

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
Forgive me David but why do I need the relays?

December 15, 2015, 06:56:40 PM
Reply #12

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
I use a $10 ESP8266 WiFi Arduino board to monitor my garage doors, relays could be added to "press the button" as well but I don't want that capability / security hole.  More info here...
http://www.homegenie.it/forum/index.php?topic=927.msg6516;topicseen#msg6516

December 16, 2015, 11:35:47 AM
Reply #13

roger.wills

  • ***
  • Information
  • Full Member
  • Posts: 53
OK, understand what the relays are for now.

December 17, 2015, 03:08:35 PM
Reply #14

petediscrete

  • ****
  • Information
  • Sr. Member
  • Posts: 220
RPI 2 using CM15Pro and CSI camera module. O/S Raspbian Wheezy. Pi boots to HG in 23 seconds.

I suggest looking at x10, in particular the shutter module. Old but fairly reliable technology and easily integrated into HG and very customisable.