Help with PIR demo

This is my first time using a BeagleBone Black (it’s a Rev C), and I started out with the “Blink on-board LED” and “Blink external LED” demos, both of which worked perfectly. Then I advanced to the PIR Motion Sensor demo, and I’m quite certain I connected everything just as they said, but I can’t seem to get it to work.

At first the LED light turned on right away, and I got a constant succession of “Motion Detected” messages. Then I realized that the code assumed an active-LOW output from the PIR, but my PIR is active-HIGH, so I changed the lines

if(x.value === 0){
b.digitalWrite(led, 1);
console.log(“Motion Detected”);

to instead be

if(x.value === 1){
b.digitalWrite(led, 1);
console.log(“Motion Detected”);

In this case the light does not come on, and I get a constant succession of “No Motion Detected” messages…and the PIR never detects motion, no matter how much I move, or how close I am. I even tried a different PIR (also active-HIGH), and got the exact same results. I also tried removing the pull-up resistor, which also did not work.

Then I found this post…

https://groups.google.com/forum/#!searchin/beagleboard/pir%7Csort:relevance/beagleboard/ydD2Cyi5fJo/QK0jHa53NMgJ

…which makes me think that the demo isn’t working because I’m not using the exact PIR sensor prescribed in the PIR Motion Sensor demo. If that is the case, where do I purchase that PIR sensor? I cannot find a link to it anywhere.

Thanks in advance for the help!

First of all, you have to watch for the voltages. BBB uses 3.3V,
whereas Arduino uses 5V. If you apply 5V to BBB, you could damage it,
but on the other hand, if you use 3.3V provided by BBB to power a 5V
sensor, it may simply be not enough for it to operate (although it
won't damage the BBB because it's unlikely to generate its own 5V).
The bottom line is you do need a 3.3V-compatible sensor.

If yours is 'active HIGH' then a pull-up resistor would probably just
peg it in a 'constantly active' state.

Just use a DVM to measure the voltage on the sensor when it's powered
by your BBB: if it shows 0V covered, and around 3V if you stick your
hand in front of it, it should work with the code above.

On Fri, 16 Dec 2016 19:33:35 -0800 (PST), Chris Fink
<chrisunderscorefink@gmail.com> declaimed the
following:

...which makes me think that the demo isn't working because I'm not using
the *exact* PIR sensor prescribed in the PIR Motion Sensor demo
<http://beagleboard.org/Support/BoneScript/PIRMotionSensor&gt;\. If that is the
case, where do I purchase that PIR sensor? I cannot find a link to it
anywhere.

  Doesn't the link at the bottom of that page work? It routed me to
SparkFun PIR Motion Sensor (JST) - SEN-13285 - SparkFun Electronics

where they describe their sensor as rated for 5-12V, and suggest jumpering
the on-board regulator to allow it to work with 3.3V... Though since it is
described as open-collector using a pull-up, you can probably power it
using the 5V pin, and use a 3.3V pin for the pull-up resistor. It should
then show as 3.3V HIGH except when the device itself asserts 0V LOW.

Additional, based on data sheet for Parallax/AdaFruit unit

On Fri, 16 Dec 2016 19:33:35 -0800 (PST), Chris Fink
<chrisunderscorefink@gmail.com> declaimed the
following:

demo <http://beagleboard.org/Support/BoneScript/PIRMotionSensor&gt;, and I'm
quite certain I connected everything just as they said, but I can't seem to
get it to work.

  Should work with 3.3V according to Parallax sheet and AdaFruit web
page, when not using a pull-up. Do you have the newer one with adjustment
pots? Possibly the adjustments are at some extreme setting (Parallax did
not have them) Also, where is the retrigger jumper placed?

Thanks for the replies, everybody. I am confused about the voltage requirements of the BBB…it accepts a 5V power supply (in the slot next to the ethernet cable input), and yet it is a 3.3V device? In addition, the demo prescribes that the PIR be powered by pin P9_5, which is a 5V supply. So if you could further explain how/why the BBB is a 3.3V device, I would appreciate it.

I am glad you brought this up, however, because I used my DVM to check the voltage supplied by pin P9_5, and it turned out to be 0…! My PIR wasn’t being powered at all. Perhaps this was because the BBB was only powered by the USB cable to my computer, and not a 5V supply? In any case, I switched the PIR’s power line from pin P9_5 to pin P9_3 (3.3V power supply). In that case the PIR was powered, and it finally did something: when I ran the demo, it continually oscillated between detecting motion and not detecting motion–even though there was nothing moving in front of it! The LED light turned on and off pretty regularly, with a period of about 5 seconds. Perhaps this is somehow due to the PIR not being supplied the full 5V?

Also, Dennis, thank you for pointing out that the demo page does in fact have a link to purchase the PIR they mention. I had only looked at the analogous page when my BBB was hooked up to the computer, and for some reason this version of the page did not include those links. Thank you for pointing that out.

On Sat, 17 Dec 2016 15:29:07 -0800 (PST), Chris Fink
<chrisunderscorefink@gmail.com> declaimed the
following:

Thanks for the replies, everybody. I am confused about the voltage
requirements of the BBB...it accepts a 5V power supply (in the slot next to
the ethernet cable input), and yet it is a 3.3V device? In addition, the
demo prescribes that the PIR be powered by pin P9_5, which is a 5V supply.
So if you could further explain how/why the BBB is a 3.3V device, I would
appreciate it.

  The first chip (U2 I believe) near the 5V power connector is a voltage
regulator which drops the voltage to 3.3V to power all the rest of the
chips. The 5V is passed through to the connectors.

  Signal pins to the main processor are only safe with 3.3V (and the
analog inputs are even more critical -- they only handle 1.8V)...

  Open collector devices (those that /need/ a pull-up resistor) are
designed such that they do not "push" a voltage to the line, they only
drive the line down to ground. When not pulling down to ground the line
floats -- the pull-up resistor is what lifts the line to a stable "high",
so a pull-up to 3.3V would be valid. Even if the device is using a 5V power
supply, it doesn't push 5V out the signal line.

  USB is also 5V (and possibly up to 500mA IF the source is not split via
a hub to multiple devices [this is USB 2.0; 3.0 has different
capabilities].

demo, it continually oscillated between detecting motion and not detecting
motion--even though there was nothing moving in front of it! The LED light
turned on and off pretty regularly, with a period of about 5 seconds.
Perhaps this is somehow due to the PIR not being supplied the full 5V?

  Sounds almost like an RC timer circuit... Again, if yours has that
retrigger jumper, how does it behave in the other position?

Amazing already explained in previous post sounds like original poster has no knowledge that modern processor are powered at 3.3 volts or less and never bothered to read schematics. I applaud the willingness to walk through the examples

Yes, thank you very much for walking through the examples, I do appreciate it. I figured out the solution: for some reason pin P9_5 (“VDD 5V,” the pin the demo says to use to power the PIR) was not working. But I discovered that pin P9_7 (“SYS 5V”) is working, so I used that to power the PIR, and now everything is working perfectly. I did play around with the re-triggering, but either setting seemed to work pretty well (one setting was more responsive, while the other one stayed on the whole time motion was detected). Thanks again for all the help!

This is also my first time using a Google Groups message board. Is there some way to officially “accept” or “like” an answer, like on stackoverflow?

P9_5 would get its power from the barrel jack
P9_7 is supplied from the PMIC
PMIC can get its power from USB or P9_5 or the barrel jack

I highly recommend reading the schematic when you design hardware for
the BBB.
can save a lot of head scratching.

On Sun, 18 Dec 2016 09:13:34 -0800 (PST), Chris Fink
<chrisunderscorefink@gmail.com> declaimed the
following:

This is also my first time using a Google Groups message board. Is there
some way to officially "accept" or "like" an answer, like on stackoverflow?

  You may be using Google Groups, but I'm accessing using the gmane NNTP
(news) server. I don't know if this is also a mailing list format -- I tend
to avoid mailing lists if NNTP if available for the same content.

  Mailing lists and news servers don't do social media "like" stuff
because there is no one host holding the contents -- posts get relayed to
other servers.

  Also -- since I've run with "X-No-Archive" ever since the creation of
DejaNews (which got sucked up by Google)... So... My posts will disappear
in a few days from Google Groups (they seem to be pulling the expiration
period ever shorter -- I wouldn't be surprised if in a few years they
expire in less than 24 hours).