# Connecting a PIR to a Raspberry PI



## balanga (Mar 15, 2018)

How do I connect the three pins of a PIR to a Raspberry Pi?


----------



## aragats (Mar 15, 2018)

As per the manual: 
pin1 = ground
pin2 = output: to any GPIO
pin3 = power: to +5V (allowable range is 4.5...20V)


----------



## Phishfry (Mar 15, 2018)

Most sensor boards use 3 leads. positive, negative and signal. You will want to hook the signal line up to a GPIO pin.
First you might need to change the direction of your desired GPIO pin. For example:
`gpioctl -c 30 IN`
For a switch you want IN for an LED your would want OUT.

You can observe your switch in action with `gpioctl -l`. It should toggle (pin 30 for example) between 1 and 0 for value.


----------



## Phishfry (Mar 15, 2018)

I think you would be better off learning a regular toggle switch first before trying to figure out more elaborate switches.

I bought one of those 37 Ardundio Sensors kits and it includes many neat devices.
https://tkkrlab.nl/wiki/Arduino_37_sensors


----------



## balanga (Mar 15, 2018)

I was hoping to connect one of these to a PiFace Digital as shown here...


----------



## Phishfry (Mar 16, 2018)

Why do you need a PiFace Digital to hook up a GPIO sensor. Read the instructions aragats so helpfully linked to.
Someone enters the sensors field of view = 1
Nothing in sensor view =0
So this is a simple digital IO signal with high/low.
You could hook it to any Pi GPIO pin. Nothing extra needed. It draws so little you can power it from the Pi power pins.


----------



## Phishfry (Mar 17, 2018)

The example of using pin 30 for Pi was wrong. It is a ground. pin 29 right next to it is a GPIO pin though.


----------

