How to Connect a PIR Motion Sensor to Electron? 5V Source?


I am right now working on a project, which includes a PIR motion sensor like it is sold in the sensor kit (HC-SR501). My issue with this is that I don’t know how to properly connect this sensor to the Electron. A document on the particle website reffered to a project where they connect this sensor to 3.3v, which kind of confuses me because the specification of the sensor tells that it needs 4.5-20v power source. I also tried to connect the sensor to the VUSB when connected to a USB power bank, which should bring me those 5v of power, but that leads to motion detection, even if there cannot be any motion at all.

Can somebody give me an advice on how to connect the sensor the right way?

Thanks a lot!

( )

Since @mohit is one of the Particle HW gurus, I’d say if he says it’s good with 3.3V then it is :wink:

The VUSB might be suffering some noise influence from the LiPo charging circuit when the powerbank isn’t very stable.
How does the PIR behave when powered off a firm USB power source?

1 Like

Yes that’s what I thought, but when reading the specs this should not be enough (4.5-20v) and it is not enough (unless I’ve done something wrong), as I tested the sensor with 3.3v and the result was no output at all.

I should try a different power source today…everything was working fine when testing the PIR with an Arduino, which obviously has those 5v.

I will report the results after testing…thanks!

I still haven’t got my Electron Sensor Kit to try it out myself, but we can ping @mohit

And alternative would be to add a 3.3V -> 5V buck converter.

1 Like

I have one. I’ll give it a try today.

1 Like

Yes that would be an alternative, but I would want to go with the USB supply if that’s possible…

I tried the HC-SR501 PIR motion detector from the Electron sensor kit. The data sheet does indeed say it requires a 5V-20V supply but as the how to shows, it really does work at 3.3V. I tried it and it worked properly for me off 3V3 as well VIN.

It’s probably a good idea to actually use the device within spec, and in that case, if you’re powering by USB, using VIN is a good choice, around 4.8-4.9V. Or if you’re using battery, a set-up converter, though at 65 mA to run the PIR sensor, you’ll get pretty limited battery life.

Like most PIR motion sensors it seems a little inaccurate when you first power it up, but then it seems to calibrate and work properly after 15 seconds or so for me.

1 Like

Ok…thanks for testing that for me. I will try it again with 3.3v (didn’t work at the first try) and hope for the best…Maybe it’s the fault of my sensor which is not from the sensor kit, but should be the same one as it is the HC-SR501 as well. I even tried it with the Arduino using the 3.3v and it didn’t work, whereas the 5v worked fine without having those weird detections i had with the 5v USB on the Electron.


I finally got the time to test the PIR with 5v of a different USB Source, which actually worked this time and even the 3.3v resulted to an output. The only problem that’s left is that I am having difficulties to find the right value for sensitivity and time (can be adjusted with a resistor). Sometimes the sensor just keeps outputting HIGH for a long time and sometimes it works as expected and turns off after not having the movement for a short time. I tried several positions and experimented with the sensor: sometimes it gets better and sometimes much worse… It seems like it makes a different how the “state of movement” or the environment is when turning on the device (power source of the sensor).

Does somebody of you know what to consider when adjusting the parameters or powering on the sensor?

@rickkas7 @ScruffR

If I understand what you’re after:

I did a project similar to this. I bought theses eBay PIR Sensors. They needed 5v for power but they only output a 3.3v signal. From there I found a buck converter on Sparkfun that you give 3.3 it returns 5v @500 mA max. In my case this was good for my PIR. I can’t remember the exact hookup but when the PIR had motion it would go low. So in code I would wait for a low on the digital pin and use a particle publish. I hope the info about the buck converter helps.


1 Like

You should also give the sensor some time to adjust after you changed the settings.
For that you may want to depower the whole system, power it up and keep still for at least 15sec and then check if you’re happy with the settings.
If not repeat - that might take some time tho’

Ok thanks…I should try that the next days when having more time


I know this thread was opened quite a time ago. However I’ve come to the second stage of testing as I want to call it. I finally bought myself 3 new HC SR501 to make sure that the issue of unexpected motion detections is not caused by the sensor itself.

Now I started my testing with these sensors again and I think that I finally found the problem that is causing the unexpected detections. Therefore it has to be said that I am using a testing program that is triggering the Particle.publish function whenever motion is detected that was not detected the loop before. However, to make sure that the Electron is not disconnecting I included the Particle.keepAlive function that reconnects the Electron ever 30 seconds. This network traffic seems to be causing a problem, whether it is the power loss that is that big, or the indicated power due to the inductor so that the sensor “detects motion” every 33 seconds (3 seconds seem to be the difference).

This problem occurs not matter if I connect the VCC to the Electrons 3.3V or to the 5V input source from the USB power supply.

A thing I thought about, that could cause this issue is that the network traffic indicates power to the sensors wire, which then leads to a HIGH input. Do you think this can be solved by adding a proper resistor or by increasing the distance between the antenna and the sensor?

Another thing to try would be to use a stronger power supply (f.e.15W) to compensate for the high power use of the network module if this is the problem. Since this is not a very good solution for just connecting an “everyday” sensor I would very much appreciate your help and your opinion.

Thank you very much,