Page 1 of 1

Detect direction of garage door motor running

Posted: Sun May 19, 2019 7:16 pm
by duckredbeard
I am looking for a way to detect which way my garage door is running. I could use the built in RPM sensor on the drive motor shaft. During operation, it produces about 3.8 VAC while the motor is running. I could use this in a program.

So at start, the door is closed. Every time it sees 3.8VAC, assume the door is moving. First time it moves it is OPENING, so the program would do a to a specific URL (that is how I get the info). When it stops, do another to say the door is STOPPED. When it sees the 3.8VAC again, assume the door is CLOSING. Again, when it stops and the 3.8VAC is gone, it is STOPPED, do another to a URL. I would have three URLs prebuilt for it to post. One for "opening" direction, one for the "closing" direction, one for the "stopped" event. I already have one for the closed state

For the RIGHT door...
Start with rmovlogic = 1 # door is CLOSED
When I GET the 3.8VAC, do a to my URL and set rmovlogic = 2 # door is OPENING
When I LOSE the 3.8VAC, do a to my URL and set rmovlogic = 3 # door is STOPPED
When I GET the 3.8VAC, do a to my URL and set rmovlogic = 4 # door is CLOSING
* every time it reverses, go back and forth between rmovlogic = 2, 3 or 4, depending on direction as long as it is not CLOSED.

If the door direction changes several times before reaching CLOSED, I want to know what its last direction was. This is populated on my phone, determined by the last URL. Each URL has it own keyword that is interpreted by my phone (opening, stopped, closing, closed).

I will take care of the closed state with a limit switch on pin 40. If that has a ground, then the door is CLOSED. When it gets closed, the rmovlogic would be reset to 1. I already have a to a URL to pass on that state.

Here's a demo of what I have now, showing the OPEN/CLOSE state monitoring. I think it is recent... ... TVS81/view

And here's how I am monitoring open/closed state of two different doors in one program:

Code: Select all

import requests
import RPi.GPIO as GPIO
import time

r ="")  #  Door monitor service is active

buttonRDPin = 15  #  Not used
buttonRUPin = 16

buttonLDPin = 38  #  Not used
buttonLUPin = 40

GPIO.setup(buttonRUPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(buttonRDPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)  #  Not used

GPIO.setup(buttonLUPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(buttonLDPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)  #  Not used

ledONPin = 32
GPIO.setup(ledONPin, GPIO.OUT)
GPIO.output(ledONPin, GPIO.HIGH)  #  LED on breadboard indicating door monitor service is active

llogic = 1  #  Initialize door state of left door, assumed to be closed
rlogic = 1  #  Initialize door state of right door, assumed to be closed
while True:
    buttonState = GPIO.input(buttonRUPin)
    if buttonState == False:
        if rlogic == 0:
            r ="")  #  Right door is open
            rlogic = 1
        if rlogic == 1:
            r ="")  #  Right door is closed
            rlogic = 0
    buttonState = GPIO.input(buttonLUPin)
    if buttonState == False:
        if llogic == 0:
            r ="")  #  Left door is open
            llogic = 1
        if llogic == 1:
            r ="")  #  Left door is closed
            llogic = 0

Re: Detect direction of garage door motor running

Posted: Mon May 20, 2019 1:15 pm
by LTolledo
Though it might not happen with your setup...

but what if the door was opening, then stopped midway, then restarted to open again until fully opened,
closing, stopped midway, then continue to close, then abruptly stopped again, then continue to close until fully closed)

if that ever happens how will your program cope with that scenario?

Re: Detect direction of garage door motor running

Posted: Mon May 20, 2019 1:41 pm
by duckredbeard
I can install another switch to detect the fully open state but I don't need that info. I am primarily concerned with the door being closed/not closed.

If the door travel stops, it will always move in the opposite of its previous direction when it starts again.

I want to detect that it is indeed moving. I believe I can capture the direction in my phone by alternating between two variables. All I would need to do is a when the 3.8V starts and another when it stops. My phone (using Tasker) can sort out the direction of travel.