Author Options:

How do I use PIR motion sensor to trigger 3v relay module? Answered

​Looking for help on my project.  See image.  Testing before connecting to high voltage device.  This is my first attempt using a relay. Using a 3v relay triiggered by the PIR signal.  As you see wired now, There is no ground wire coming from PIR only Red + and Yellow signal to relay..  The circuit would not trigger relay with a ground wire to the PIR.  When this does trigger ( without the ground wire on PIR) I noticed on the relay that the LED would not go completely off.  It dimmed showiing that the relay board was still receiving power. So I check to find that when relay turns/switches "off"  the PIR is still sending 2.6-2.8 volts to the relay.  Not enough to trigger the relay, but enough to show power through the LED.  Obviously something wrong here where the PIR or Relay are still drawing power.  Can you help?



Best Answer 2 years ago

I think you need a MOSFET because the PIR sensor does not output enough current to drive the relay directly. First thing, make sure the 9V battery itself can activate the relay even as it gets drained. Test a fresh one and old one. Also, see what the PIR sensor output is. Hopefully when activated it is high enough to drive a MOSFET. small MOSFETs (the SMD ones found on many devices) generally need about 3V to turn on, while larger TO220 ones like IRF540 need over 5V to be turned on as hard as possible (threshold voltage around 2--4v with that particular part). If you don't have a spare MOSFET somewhere, a BJT transistor should also be suitable. BJTs do need some base current however but can be turned on with about 0.7v or so.

Max... I will try your solution. Excuse my ignorance... but I am a complete novice at this...

Can you explain how the set up as I have it can drive the relay without a ground on the PIR? When the ground is connected to the PIR there is not enough current to drive the relay? Suggestion where I might salvage a MOSFET without having to wait for them to arrive in snail mail?

No problem! This video should teach you all you need to know to get started with transistors, specifically MOSFETs. The first transistor I learned about was the Bipolar Junction Transistor, or BJT, but these are (arguably) older technology and are falling out of style rapidly. I recommend MOSFETs for their better switching capabilities and (for the most part) high input impedance. You need absolutely no current to drive the MOSFET, the MOSFET will handle powering the relay for you. Just apply a voltage to the gate of the MOSFET to control its resistance. The gate looks like a tiny capacitor connected to ground, so it's easy to drive so long you don't need super fast switching times. Of course, being like a small capacitor, if you want to turn it on and off really fast, you'll need something that can deliver high pulses of current to charge and discharge the gate quickly. But don't worry about that, we are not trying to make a switchmode power supply or RF oscillator here.

To wire it up correctly, connect the ground of the PIR to ground, and +Vcc to +Vcc and the signal wire to the gate of the MOSFET. Connect the MOSFET source to ground, and the drain to one end of the relay with the other end connected to +Vcc. N channel MOSFETs are absolutely everywhere in modern electronics if you hunt around for them. The problem is so are voltage regulators, voltage references, BJTs, JFETs, and diodes, and there's little to no correlation between what type of part you might have and what it is. MOSFETs, diodes, and other types of transistors can all look the same. I have several diodes in 3 pin TO220 packages that look like transistors or voltage regulators. Other times I have found MOSFETs in the SMD DIP style packages that you would expect to be small IC's!

The only way to tell for sure is to either experiment with the parts or research the part numbers on them. Almost all modern circuit boards will have tiny little surface mount transistor MOSFETs on them but they are really hard to deal with because they are only a little bigger than grains of salt, and soldering 30AWG magnet wire to give them leads that can plug into a breadboard is a challenge it it of itself. I have done that a few times though! Those tiny mosfets are particularly nice because they can be usually be turned on at low voltages (2v or so threshold voltage). 

Power supply boards are my favorite type of board to salvage parts from because many of the parts are through hole parts and not difficult to deal with once desoldered. Below are some links to pictures of what to look for on your salvaged electronics power supply boards and stuff:





Hello Max,

Received the Mosfets today. Below is my wiring diagram that I have not yet tested. Missing one connection from your instructions. The signal input to relay is missing. How should I connect the input signal? Any changes you think should happen?



The relay spec suggests you SHOULD be able to drive it fine, there's a transistor on the relay board already, doing the work, no need for an extra one, I had already allowed for it, in our discussions yesterday.

Like I said, wire it up and make some measurements.

Through my testing voltages and finding that the voltage was dropping from the PIR 3.3 volts to 2.8 volts once it was connected to the 3v relay. So in my research of learning about MOSFETs and how to up the voltage I learned of Voltage Level Shifting. Apparently there are many methods on how to level shift. Besides the MOSFET method I learned of using a 2N2222 transistor and resistors. I figured I would try whatever comes in the mail first.

Transistors and resistors arrived first (still waiting on the MOSFET) Currently have a level shifting circuit working somewhat. I have a 9v source for PIR and 5v source for the relay. But I have an odd behavior. The PIR is operating reverse as it should. In other words with NO motion the relay triggers. With motion the PIR deactivates the relay. Any ideas?

"The PIR is operating reverse as it should." Lol, I think it is because you made a inverting amplifier. It level shifts, but it also inverts the signal. There are a few ways you can wire up transistors for different modes of operation. Each configuration has its pros and cons. How did you wire the transistor up?

Max... here is my how things are wired.

PIR 3v relay_bb.png

Ha Ha.. Max. you caught my late night typo. No the PIR should NOT be working in reverse or inverted as you put it. How did I wire the transistor? Obviously the WRONG way. LOL! Going to attempt a breadboard schematic and upload it hear. Thanks for your response and catching my typo.


Just wanted to give an update. Still going to try some of the level shifting solutions that have been suggested, but in the meantime, here is my solution.

Put the ground back, and get a voltmeter on the output pin. See what voltage you get from detect to not-detect, disconnected from the relay, and then connected back to the relay.

I can't see any wiring instructions for the relay. on the link you sent unfortunately. Its possible the links need setting differently.

The relay isn't going to like being run from a 9V supply, if its a 3V relay coil, so be careful there.

Thanks for your continued help.

With ground connected to PIR and PIR disconnected from Relay... Voltage coming from output pin at PIR is 3.31 volts.

Now going back to no ground connected to the PIR when Relay does trigger, there is 3.26 volts from PIR output to relay. ODD.

Any idea the purpose of the jumpers on the relay board?

No, all I can tell is that it has some. Do you have any instructions for it ?

I suspect the 9V is an issue here.

Pretty well as you have, with the ground on the PIR.

I'd like to see what the board tracks look like in more detail, but I can't see the details on the EBAY pictures

Your relay is "opto isolated" (the 4 pin black box), which reduces the possibility of damaging the PIR. Put everything back, and see what happens when the PIR triggers, to the input voltage at the relay. I expect to see it go up to around 1.2V. I suspect the Relay board wants more mA to trigger it than the PIR can give it.

Hmmmm... just had a thought. If relay is rated 3v/3.3 and signal coming to relay is 3.31 volts, is this too much voltage? Relay protection possible? If so, will an inline resistor fix the problem between PIR and Relay?

SUPPLY to relay is already 9V. The "signal" triggers a little transistor, which then turns on the relay, looking at the diagrams. Its very hard to tell.

Please sketch what you have, its impossible to follow from a photograph.

steveastrouk... thanks for the reply. Again note... their is no ground coming from PIR. This circuit triggers relay, but there is a constant 2.6 - 2.8 volts going to relay after the relay switches off from the allowed time from PIR. This keeps the light indicator on the relay dimmed. I am guessing there should be 0 voltage with no light. Hope you or somebody else can help.

PirRelay Drawing.jpg

OK, some links to what you bought would help too. I don't think the PIR will like working with no ground.

thank you, but your solution does not take into consideration the need for the IN terminal to the relay.