Help with setting up PIR sensors


38 posts   Page 1 of 2   1, 2
by Happy2013 » Mon Feb 11, 2013 2:34 pm
Hello,

I am wanting to set-up 2 PIR sensors and 2 LED's using the Pi's GPIO. These will be connected to an external solder-less breadboard using the Adafruits Cobbler. The idea I have for this is that one sensor is at the top of the board and the other is located at the opposite end both will also have LED's with close proximity. I am not to good with creating circuits etc and am looking for some assistance setting this up and even if its possible to have two PIR's connected to the PI running on 3.3v and through the one GND pin connection.

Here are the PIR sensors I have purchased, they have 3 legs.

http://uk.farnell.com/panasonic-ew/amn3 ... tt=1373712

Thanks
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by joan » Mon Feb 11, 2013 2:59 pm
I guess the two PIRs are to be inputs so will need common input connections to ground, +3.3V and distinct output connections to gpios.

What are the LEDs for? For instance are they meant to go on if a PIR detects movement?
User avatar
Posts: 6558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Happy2013 » Mon Feb 11, 2013 3:07 pm
Yes you are correct as for the LED's they are supposed to light up when movement is detected
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by joan » Mon Feb 11, 2013 3:19 pm
OK.

Connect Pi ground to breadboard ground (usually breadboards have outer rails which are common, one is arbitrarily chosen as ground).

Connect Pi 3V3 to the other outer breadboard rail.

Connect PIR 1 inputs to breadboard ground and 3V3. Ditto PIR 2.
Connect PIR 1 output to a spare Pi gpio. Ditto PIR 2 (different spare gpio).

Connect LED 1 to breadboard ground via a 330 ohm resistor. Ditto LED 2 (its own resistor).
(LEDs are directional so connect the negative end to the resistor connected to ground).

Connect a spare gpio to LED 1. Ditto LED 2.

The rest is software.
User avatar
Posts: 6558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Happy2013 » Mon Feb 11, 2013 3:43 pm
Thanks for your reply, Do I not need anything else on the PIR sensor circuit to control the current etc...... Can I also connect two PIR to the one 3.3 PIN?

The breadboard I have has a large number of slots in the middle and on either side +/- rail, does the LED only need to connect to one PIN as I was under the impression that it requires two!
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by joan » Mon Feb 11, 2013 4:13 pm
What you need is four independent circuits with a common ground (rail) and a common 3V3 (rail). You'll have 2 PIR circuits acting as inputs and 2 LED circuits as outputs.

Search for example LED and PIR breadboard circuits and you'll get the idea.
User avatar
Posts: 6558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by Happy2013 » Tue Feb 12, 2013 10:23 pm
Do I not need any resistors connected on the PIR ciruit? I
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by joan » Tue Feb 12, 2013 10:27 pm
No resistors required on the PIR. If you power it from 3.3V it is safe to use as an input to the Pi.

The LED has two wires. One (+ve) will be connected to a gpio, the other (-ve) to a resistor which is then connected to ground.
User avatar
Posts: 6558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by techpaul » Wed Feb 13, 2013 5:15 pm
Happy2013 wrote:I am wanting to set-up 2 PIR sensors and 2 LED's using the Pi's GPIO. These will be connected to an external solder-less breadboard using the Adafruits Cobbler. The idea I have for this is that one sensor is at the top of the board and the other is located at the opposite end both will also have LED's with close proximity. I am not to good with creating circuits etc and am looking for some assistance setting this up and even if its possible to have two PIR's connected to the PI running on 3.3v and through the one GND pin connection.

Here are the PIR sensors I have purchased, they have 3 legs.

http://uk.farnell.com/panasonic-ew/amn3 ... tt=1373712

Thanks

The PIRs you have chosen are nice units I have used before, with current outputs, you need to connect
  • The output pin of EACH PIR to a separate GPIO pin for each PIR INPUT
  • The output pin of EACH PIR should also connect to one end of a resistor (almost any value bewteen 10k and 100k will do)
  • The other end of each resistor connected to GND
As to the LEDs connect each LED to its own GPIO pin used for output as per the many LED examples about through a resistor to 3V3 or 5V depending on your taate and brightness required.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Happy2013 » Thu Feb 14, 2013 12:50 am
Thanks for the information, dont mean to be a pain, but any chance you could point me to a circuit diagram for this setup.
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by techpaul » Thu Feb 14, 2013 2:12 am
Try these
PIR-GPIO.gif
PIR to GPIO in INPUT mode
PIR-GPIO.gif (8.78 KiB) Viewed 1586 times
Resistor is 100k max 10k min

LED driving direct for only a couple of LEDs, more really needs drivers for higher brightness and longer life of whole circuit and Pi
LED-Direct.gif
Direct LED driving
LED-Direct.gif (8.03 KiB) Viewed 1586 times
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Happy2013 » Thu Feb 14, 2013 6:12 pm
Thanks for this, will give this a shot over the weekend and let you know how it goes.

Thanks
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by Happy2013 » Thu Feb 14, 2013 6:38 pm
on the bottom of these, there are three pins two are identical and the other has a gold bottom. Am I write in thinking that this is the VDD and the other two don;t make a difference which way round they are! Data sheet link below

http://www.farnell.com/datasheets/73642.pdf
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by hendrixjl » Thu Feb 14, 2013 6:45 pm
Just curious techpaul: what did you use to draw those diagrams?
Thanks,
Posts: 50
Joined: Sun Nov 04, 2012 9:22 pm
Location: Huntsville, Alabama, USA
by Happy2013 » Thu Feb 14, 2013 7:32 pm
It looks like Eagle I believe
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by joan » Thu Feb 14, 2013 7:47 pm
Happy2013 wrote:on the bottom of these, there are three pins two are identical and the other has a gold bottom. Am I write in thinking that this is the VDD and the other two don;t make a difference which way round they are! Data sheet link below

http://www.farnell.com/datasheets/73642.pdf

The datasheet shows the orientation of the pins.

I wouldn't drive LEDs on the Pi with 5V for any great length of time. I suspect you won't either.
User avatar
Posts: 6558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by techpaul » Thu Feb 14, 2013 8:15 pm
Happy2013 wrote:It looks like Eagle I believe

Yes Eagle 6.3 there is a free version for boards up to 100 x 100 mm and two layers
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by techpaul » Thu Feb 14, 2013 8:17 pm
joan wrote:
Happy2013 wrote:on the bottom of these, there are three pins two are identical and the other has a gold bottom. Am I write in thinking that this is the VDD and the other two don;t make a difference which way round they are! Data sheet link below

http://www.farnell.com/datasheets/73642.pdf

The datasheet shows the orientation of the pins.

I wouldn't drive LEDs on the Pi with 5V for any great length of time. I suspect you won't either.

Well you can drive them from 3V3 better, was quick hack of similar circuit meant for my GPIO boards for 5V translated operation.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by joan » Thu Feb 14, 2013 8:29 pm
techpaul wrote:
joan wrote:
Happy2013 wrote:on the bottom of these, there are three pins two are identical and the other has a gold bottom. Am I write in thinking that this is the VDD and the other two don;t make a difference which way round they are! Data sheet link below

http://www.farnell.com/datasheets/73642.pdf

The datasheet shows the orientation of the pins.

I wouldn't drive LEDs on the Pi with 5V for any great length of time. I suspect you won't either.

Well you can drive them from 3V3 better, was quick hack of similar circuit meant for my GPIO boards for 5V translated operation.

Sorry - couldn't resist. ;)
User avatar
Posts: 6558
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by techpaul » Thu Feb 14, 2013 8:34 pm
joan wrote:
techpaul wrote:
joanI wrote: wouldn't drive LEDs on the Pi with 5V for any great length of time. I suspect you won't either.

Well you can drive them from 3V3 better, was quick hack of similar circuit meant for my GPIO boards for 5V translated operation.

Sorry - couldn't resist. ;)

No need for apology, also very busy with half a dozen different Pi related things as well as my main paying work...
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Happy2013 » Sat Feb 16, 2013 7:24 pm
Hello,

Ive been giving this a shot today and for some reason reason my pir seems to be constsntly high as its always lighting the led even when im out of range. For test purposes im only using the one PIR and my system is set up as follows:

3.3v pin 1 to outter breadboard
rail on.

GND pin 6 to breadboard rail opposite side of above.

PIR power to breadboard rail 3.3v

PIR input to pin 15

PIR GND to breadboard GND rail

Pin 11 to led for power

220r from led to gnd rail

Can post my code if needed, however I am sure it is fine.

Thanks
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by techpaul » Sat Feb 16, 2013 7:32 pm
Put a resistor of a value between 10k and 100k between the PIR OUTPUT and GND.

The PIR output is very low quiescent current because the output drive is a switch that applies power to the output on detection, at other times the output is OFF.

Therefore your GPIO pin is floating when no detection and could be reading anything.

Alternatively set your GPIO Input to have pull down resistor.

I did say this about 3 posts back
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Happy2013 » Sat Feb 16, 2013 7:37 pm
I know but the way my wires are set up using male I dont have room, as the sensor takes up half of the board
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm
by techpaul » Sat Feb 16, 2013 7:42 pm
Happy2013 wrote:I know but the way my wires are set up using male I dont have room, as the sensor takes up half of the board

Without the resistor it will NOT work properly and those PIR sensors are quite small, so you must have a really small board.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by Happy2013 » Sat Feb 16, 2013 7:59 pm
Ive just placed the resistor between them and same issue is occuring
Posts: 25
Joined: Mon Feb 11, 2013 2:26 pm