duckredbeard
Posts: 46
Joined: Mon Apr 29, 2019 1:53 am

Detect direction of garage door motor running

Sun May 19, 2019 7:16 pm

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 requests.post to a specific URL (that is how I get the info). When it stops, do another requests.post 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 requests.post 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 requests.post to my URL and set rmovlogic = 2 # door is OPENING
When I LOSE the 3.8VAC, do a requests.post to my URL and set rmovlogic = 3 # door is STOPPED
When I GET the 3.8VAC, do a requests.post 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 requests.post 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 requests.post 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... https://drive.google.com/file/d/1jKu4pB ... 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
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

r = requests.post("http://bit.ly/xxxxxxx")  #  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 = requests.post("http://bit.ly/xxxxxxx")  #  Right door is open
            rlogic = 1
    else:
        if rlogic == 1:
            r = requests.post("http://bit.ly/xxxxxxx")  #  Right door is closed
            rlogic = 0
    buttonState = GPIO.input(buttonLUPin)
    if buttonState == False:
        if llogic == 0:
            r = requests.post("http://bit.ly/xxxxxxx")  #  Left door is open
            llogic = 1
    else:
        if llogic == 1:
            r = requests.post("http://bit.ly/xxxxxxxx")  #  Left door is closed
            llogic = 0
    time.sleep(0.1)


You can't know your limits until you exceed them.

LTolledo
Posts: 1515
Joined: Sat Mar 17, 2018 7:29 am

Re: Detect direction of garage door motor running

Mon May 20, 2019 1:15 pm

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,
or
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?
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

duckredbeard
Posts: 46
Joined: Mon Apr 29, 2019 1:53 am

Re: Detect direction of garage door motor running

Mon May 20, 2019 1:41 pm

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 requests.post when the 3.8V starts and another when it stops. My phone (using Tasker) can sort out the direction of travel.
You can't know your limits until you exceed them.

Return to “Automation, sensing and robotics”