1

I'm new to working with RPi GPIOs, and I never studied electronics so bear with me on this newbie question.

I have an RPi 2 Model B, and I'm tasked with detecting a motion detector alarm going off.

Here's how the motion detector looks Motion detector

The detector signals an alarm going off with opening the circuit on RELAY pins. AFAIK it works like a push button (opens the circuit for 4 seconds if it detects motion).

The question is how do I use GPIO pins to detect the alarm.

  • Do I connect an output GPIO to an input GPIO through the RELAY? Can I even do so?

  • Do I connect 3.3v VDC power pin to an input GPIO pin through RELAY?

  • Any other ways?

I do not have access to a breadboard, I basically connect everything directly with wires.

Please remember that I'm a newbie so technical answers with schematics are not gonna help too much, unless they're accompanied with an explanation for 5 year olds.

Here's the overall look of what I have and how I connect everything Overall view

Thanks in advance!

  • There is no way of knowing. It's like pointing to a pixelated image of an Ikea flat-pack and asking how it should be assembled. We need hard facts like links to specs of the motion detector. – joan Apr 30 at 8:24
  • The documentation of the detector is in Russian. Here's the link though link – andranik3949 Apr 30 at 8:36
  • The thing is, I'm more concerned about not damaging the RPi, because a friend of mine connected this detector to an Arduino, and it worked fine, even without any resistance. I'm worried about shorting the RPi pins, because I found no instances where people just connect an output GPIO to an input GPIO directly. – andranik3949 Apr 30 at 8:40
1

If the relay pins are a simple contact closure (which seems likely, but no one can confirm - although it is easy to verify with a multimeter) then you can use any button code.

See https://www.raspberrypi.org/blog/gpio-zero-a-friendly-python-api-for-physical-computing/

Specifically https://gpiozero.readthedocs.io/en/stable/recipes.html#button

Connecting to pin 3 and 6 is easy - no pullup needed.

No need to connect to ANY Pi output.

Incidentally, using an ATX power supply is a really bad idea - get a 5V power pack.

  • Thanks for the answer! Exactly what I needed! – andranik3949 Apr 30 at 9:44
  • 1
    Also, why not use an ATX? I used it as I wanted both 12v and 5v power supply, cause I need 12v for the sensor – andranik3949 Apr 30 at 10:18
  • @andranik3949 ATX has 3V3, and also touch button on, LED status. I love it. – tlfong01 Apr 30 at 13:11
-1

Question

How to use Rpi python to detect motion sensor signal and switch on a relay.

Answer

Your Russian connection looks OK. I can write you a python program (no guarantee your Ppi won't explode!) to detect the motion output signal.

The problem now is: If you cat comes in, the motion sensor gives a warning signal to Rpi (at GPIO pin 17), so Rpi will switch on the relay. So far so good, except the signal might be too strong and kill Rpi sooner or later, if not instantly.

If you have a multimeter and know how to measure voltage, you or your friend can use it to see if the output signal is higher than 4V (very likely) and can kill Rpi.

And one more thing, where is the relay?

Perhaps you can ask you Arduino friend if the motion sensor has a relay inside (not likely), if not, does Rpi need to use another GPIO pin to switch on the relay?

Or ask your friend to come over here and show us his program. We can look at the program and guess where is the relay. :)

motion detect

  • Thanks for the answer. I guess I wasnt clear enough. The sensor itself controls the relay. So when it detects motion it disengages the relay, thus breaking the circuit between the two connected GPIO-s. So all I have to do is check whether the current flows from one GPIO to another, and if it doesnt, ring an alarm. Also it would be nice not to brick the RPi whilst doing that – andranik3949 Apr 30 at 9:55
  • Ah, I see what you mean. Usually that "thing" is not called a "relay" but a "reed" switch. When the reed switch is on, means contacts make and current can flow through. The advantage of this design is that the two wires at the two ends of the reed switch can be very long, say one hundred meters. And it is sort of DC static level, and a digital pulse signal, so not that easily interfered by mains noise etc. Yes, indeed you only need one GPIO pin to check if the reed switch is closed. Perhaps I can show you the standard circuit later. I know five year child won't understand. :) – tlfong01 Apr 30 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.