Page 1 of 1

ePIR always shows True. [Solved]

Posted: Sun Dec 23, 2012 2:18 am
by alcaron
Ok, so this is my very first Rpi project, I'm trying to hook up a ePIR from sparkfun.

Pins 1,3,4 and 8 are all GND.
Pins 2,6 are 3.3v.
Pin 5 is GPIO18.
Pin 7 is GPIO17.

http://www.sparkfun.com/datasheets/Sens ... PS0284.pdf

I was trying to adapt this:
http://ninjablocks.com/groups/raspberry ... ir-sensor/

Now, what happens when I run the script is it just says "No Motion." over and over.

As I was looking over the spec I thought maybe it was because Pin 6 in his guide is set to 3.3v, but if you look at the spec sheet it says GND-1.0v means MDT will go active when motion is detected and setting it to Vdd prevents MDT from going active. However jumping Pin 6 to GND did...nothing.

The only real troubleshooting I know how to do is to see what happens when I disconnect the device, at which point the script says False instead of True but past that I don't really know how else to troubleshoot it. Any ideas?

Code: Select all

GPIO.setup(17, GPIO.OUT)
GPIO.setup(18, GPIO.IN)
GPIO.output(17, GPIO.HIGH)

input_value = GPIO.input(18)
print(input_value)
while 1:
        if GPIO.input(17):
                print('No Motion.')
        else:
                print('Motion?')
        sleep(2)
GPIO.cleanup()

Re: ePIR always shows True.

Posted: Sun Dec 23, 2012 10:32 am
by joan
It seems to default to serial link mode. Have you tried using the serial link to communicate with the device?

Re: ePIR always shows True.

Posted: Sun Dec 23, 2012 4:39 pm
by alcaron
Hardware Interface Mode Selection
The Hardware Interface Mode is selected when TXD/SNS is between 0 V and 1.8 V
during power ON or when exiting SLEEP Mode.
TXD/SNS is set to ground so, that should be setting it to HWI correct?

I have not tried connecting in serial, they described it as more advanced so I figured for my first time I'd use the "easy" way lol. I'll look into serial mode, but ultimately I would still like to figure out how to use it in HWI.

Re: ePIR always shows True.

Posted: Sun Dec 23, 2012 4:41 pm
by alcaron
Also, am I wrong to think that just running a lead from the 0.0v pin on the Rpi would set it to 0v? This is a terrible time for my stupid multimeter to flake out. But they make no mention of pin 4 being driven at all so again, hooking it up to nothing should be the same as setting it to ground yeah? Air is going to be 0.0v.

Note I have no resistors at all in this mix as it takes 3.3 so thats fine, and everything else is set to ground or GPIO.

Thanks for the input!

Re: ePIR always shows True.

Posted: Sun Dec 23, 2012 4:57 pm
by alcaron
Thanks when I try to hook it up in serial I will bear that in mind! I do think I'm going to try a bit longer to get it to work in HWI over the GPIO, partially because, well, I want to figure out how to work with GPIO, but also because it just seems more suitable for what I'm using it for.

Thanks!

Re: ePIR always shows True.

Posted: Sun Dec 23, 2012 8:26 pm
by alcaron
Ok, I figured it out.

First, the code (as that was the real problem).
from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

GPIO.setup(25, GPIO.OUT)
GPIO.setup(24, GPIO.IN)

GPIO.output(25, True)
sleep(3)
while 1:
input_value = GPIO.input(24)
print(input_value)
sleep(1)
GPIO.cleanup()
I set Pin 6 back to VDD (3.3v) and now when I run that script it properly changes from true to false (and back) based on motion detection!

Awesome! I know this is probably basic as heck old hat to you guys but this is now my first working example of GPIO, with something I couldn't find any plug and play code for, so I'm pretty pleased right now. :)

Thanks so much for the input guys, you got me thinking laterally and that was crucial, really appreciate it!