pi and passive infrared sensor

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
bill2009
 
Posts: 6
Joined: Mon Oct 21, 2013 1:22 pm

pi and passive infrared sensor

Post by bill2009 »

I have a parallax PIR sensor wired to my pi via the pi cobbler. + on the PIR is connected to 5V0 on the cobbler, - to pin labelled GND, OUT to pin labelled #25.(picture attached)

If I just power the pi, the reading on out is what I expect - 0v unless I put a hand in range then it goes to 3.2V for a few seconds. If I run the code though, it immediately goes to 3.2V and stays there (with occasional brief dips to 0v).

Clearly the code isn't right but I don't know why. I have tried a 10K resistor from OUT to ground and playing with the pullup/down specifications in the setup call but it didn't seem to change anything. The same thing happens with pin #24.

I'm using a raspbian image i downloaded with noobs a few days ago. The pi is a model B version 2.

Image

Image

bill2009
 
Posts: 6
Joined: Mon Oct 21, 2013 1:22 pm

Re: pi and passive infrared sensor

Post by bill2009 »

hah! I did all the sudo apt-get stuff and it suddenly started working right.

I THEN REBOOTED AND IT's RIGHT BACK WHERE IT WAS!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: pi and passive infrared sensor

Post by adafruit_support_mike »

Glad to hear you have it working. Happy hacking!

bill2009
 
Posts: 6
Joined: Mon Oct 21, 2013 1:22 pm

Re: pi and passive infrared sensor

Post by bill2009 »

adafruit_support_mike wrote:Glad to hear you have it working. Happy hacking!
nope, after a reboot it is doing the same thing - stuck at 3.2V

I don't know if the problem is the cobbler or my unfamiliarity with linux but it's pretty frustrating. This is the most basic thing anybody would want to do with the pi/cobbler and it just doesn't work.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: pi and passive infrared sensor

Post by adafruit_support_mike »

Hmm.. let's test a couple of things:

Connect the sensor's VCC and GND pins to the RasPi, but disconnect the jumper between the sensor's OUT pin and the RasPi. Repeat the same sequence you've already done, testing it without the code running, then running the code.

With no connection to the RasPi, you'd think the sensor will continue to behave normally, but let's verify that.

At the same time, let's see what that GPIO pin is doing. Make a voltage divider between the RasPi's 3.3v pin and GND with a couple of 10k resistors, then connect the GPIO pin to the center of that divider. Without the GPIO pin connected, the voltage at the center of the divider should be 1.65v. Check that during the part of your test before you run the code, then check again after you start running the code. If there's an internal pull-up or pull-down resistor connected, you should see some change in the voltage at the center of the divider. If you have 100k resistors, those will make the change even more visible.

bill2009
 
Posts: 6
Joined: Mon Oct 21, 2013 1:22 pm

Re: pi and passive infrared sensor

Post by bill2009 »

adafruit_support_mike wrote:Hmm.. let's test a couple of things:

Connect the sensor's VCC and GND pins to the RasPi, but disconnect the jumper between the sensor's OUT pin and the RasPi. Repeat the same sequence you've already done, testing it without the code running, then running the code.

With no connection to the RasPi, you'd think the sensor will continue to behave normally, but let's verify that.

At the same time, let's see what that GPIO pin is doing. Make a voltage divider between the RasPi's 3.3v pin and GND with a couple of 10k resistors, then connect the GPIO pin to the center of that divider. Without the GPIO pin connected, the voltage at the center of the divider should be 1.65v. Check that during the part of your test before you run the code, then check again after you start running the code. If there's an internal pull-up or pull-down resistor connected, you should see some change in the voltage at the center of the divider. If you have 100k resistors, those will make the change even more visible.
ok. thx - good suggestions. i won't be able to get at it til tonight but i appreciate your time.

bill2009
 
Posts: 6
Joined: Mon Oct 21, 2013 1:22 pm

Re: pi and passive infrared sensor

Post by bill2009 »

Ok, I'm pretty sure the problem is with the PI's 5V supply. I tried the sensor from my arduino and it was fine so I connected the PIR power to the arduino's rail which shows 5.1V it behaves normally. If I power it from the PI's GPIO 5V which shows just under 4.9V it it goes to the failure mode - generally always high but occasional drops to 0v.

The sensor data sheet says it's good from 3.5 to 5v but i guess not!

I guess I'll let the arduino run the halloween automation. I'll see if i can get the pi to do sound effects and camera duty. If I come across another PIR sensor sometime i'll try it and I'll look for a beefier power supply cable - the wall wart already says it does 5.2V and trying other usb supplies generally gets lower 5v readings at the pi's GPIO.

Thanks for your help.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: pi and passive infrared sensor

Post by adafruit_support_mike »

How much current does the PIR use?

The RasPi is known to have fairly tight power limits. It's a side effect of the tradeoffs necessary to hit the size/price/performance targets of the original design. If the PIR wants a lot of current, the RasPi might not be able to deliver enough.

bill2009
 
Posts: 6
Joined: Mon Oct 21, 2013 1:22 pm

Re: pi and passive infrared sensor

Post by bill2009 »

the data sheet says 3ma. I assume that the problem is not the pi but the sensor. if the sensor is powered from the pi's 4.8v the it gives bad readings.

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: pi and passive infrared sensor

Post by adafruit_support_bill »

it it goes to the failure mode - generally always high but occasional drops to 0v.
This is typical for these sensors. It happens when powered by Arduinos too - or even powered direct from a 5v supply. If you search the forums you will find several threads on the subject.

The re-triggering circuit occasionally drops the output to zero. This is not dificult to filter in code. It's pretty much the same logic as switch debouncing, but with a longer time constant.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”