1
\$\begingroup\$

I am trying to turn on some LEDs with a Raspberry Pi using PIR.

I have purchased,

The PIR provided is slightly different to the one in the listing as it has four terminals.

Four terminal PIR sensor

For the sake of clarity, the markings in the photo read;

Output  Input
Load    Power
A   N   N   L
|   |   |   |

What does the A stand for and do? Is this the switched live? I guess the others are Neutral and Live.

I know that PIR hats which have been designed specifically for the Raspberry Pi do exist. While these are great for robots, they are not so suited for permanent in-ceiling installation. This is going in my ceiling, so I need a solution that looks OK.

Questions!

  • How can I take a signal from this PIR and safely put that into the Raspberry Pi?
  • I understand that this PIR is expecting mains in and mains out, so should I used a relay between it and the Raspberry Pi?
  • If so, which relay?
  • How should I wire it?
  • Can I put the input N and L directly into mains?
  • Regarding the physical cable to use, can I run 2.5mm twin and earth to this PIR, or does it need something else? Four core?
  • Have I purchased the wrong PIR and would a 12v PIR be better/easier?

I have only ever used the little relays for getting the Raspberry Pi to control mains devices, not getting mains devices to control the Raspberry Pi. Any explanation on the variables of relays would be tremendously appreciated.

PS Just to be clear, I am not asking for product recommendations, just how to get PIR into a Pi.

\$\endgroup\$
4
  • \$\begingroup\$ What's the Pi adding, exactly? Why not just turn the LEDs on with the PIR? \$\endgroup\$
    – Finbarr
    Jul 29, 2021 at 8:24
  • \$\begingroup\$ I want to be able to change the colour and timing of the lights in software, so that I do not have to rip up the floorboards. \$\endgroup\$ Jul 29, 2021 at 8:54
  • \$\begingroup\$ Would something like this be better? amazon.co.uk/dp/B07S2Z9VH3 \$\endgroup\$ Jul 29, 2021 at 8:55
  • \$\begingroup\$ @JamesGeddes - Hi, I have removed your Amazon affiliate link for the Raspberry Pi which you put into the question, and replaced it with a plain link. Please do not use affiliate links on this site, as readers may then (correctly) flag your post as spam. Once you have seen this warning, I'm happy to remove the comment, so please reply that you acknowledge it. Thanks. \$\endgroup\$
    – SamGibson
    Jul 29, 2021 at 14:11

1 Answer 1

1
\$\begingroup\$

Assuming that you have to use that particular PIR sensor and that, for safety reasons, you can't design something custom that is plugged to the main, your idea to use a relay is good.

I suggest that you acquire a relay that can be controlled by the main voltage.

You will connect its control coil to the A and N port of the PIR.

Then you can connect the 3.3V pin of Raspberry Pi header connector to one end of the relay switch.

connect any GPIO of the raspberry Pi to the other end of the swith. (don't forget to add a pull-down resistor)

And voilà...

Just read the GPIO state and your Pi can know the state of the PIR

schematic

simulate this circuit – Schematic created using CircuitLab

Concerning the section of your wires. I don't know in which country you are located thus the rules may not be applicable to you. But, if you have a doubt about the section of your wire, you should use the same section as the wire in your walls.

Why? You may ask.

Of couse the power consumption of you setup is way too small to require such cables, but, in case of a problem in your setup, the current may get bigger and you small wire will become very hot and may put up a fire. This is really the worst case!

Your circuit breaker won't do anything if the fault current can be handled safely by the cable in your walls. The breaker are designed for that and their tripping current is chosen in accordance with the gauge of the wire they are meant to protect.

Thus, if you use the same wire gauge in your setup than in your walls, then if the current becomes too high for your wires, it will also become too high for your home wires and the breaker will trip.

\$\endgroup\$
7
  • \$\begingroup\$ What does the A on the PIR mean? \$\endgroup\$ Jul 29, 2021 at 9:50
  • \$\begingroup\$ I don't know why they named that port "A" \$\endgroup\$
    – Blup1980
    Jul 29, 2021 at 9:53
  • \$\begingroup\$ Weird. What does it do? Am I correct in thinking that it is the switched live? \$\endgroup\$ Jul 29, 2021 at 9:58
  • 1
    \$\begingroup\$ Yes, It is the switched live. With no doubt. I just don't know why they named it "A". But it's for sure the switched live \$\endgroup\$
    – Blup1980
    Jul 29, 2021 at 10:00
  • \$\begingroup\$ Also, I am in England so I will stick with twin and earth as you suggest. \$\endgroup\$ Jul 29, 2021 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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