Shop OBEX P1 Docs P2 Docs Learn Events
PIR sensor error? — Parallax Forums

PIR sensor error?

raulduke1011raulduke1011 Posts: 17
edited 2008-06-13 23:12 in BASIC Stamp
Does anyone have any suggestions as to what can cause the PIR sensor results to make no sense? I have it hooked up to my bs2sx and am using the code below. It will either show movement(1) for no reason or not sense movement when it should. Thanks.

FOR i = 1 to 30
IF (IN0 = 1) THEN
' handle movement'
ELSE
' no movement
ENDIF
PAUSE 100
NEXT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-06-13 21:12
    Have you given it time to warm up and calibrate itself? From the documentation:

    "The PIR Sensor requires a ‘warm-up’ time in order to function properly. This is due to the settling time involved in ‘learning’ its environment. This could be anywhere from 10-60 seconds. During this time there should be as little motion as possible in the sensors field of view. "

    -Phil
  • raulduke1011raulduke1011 Posts: 17
    edited 2008-06-13 21:36
    I was giving it 15 seconds to calibrate but only at the start of the program. I currently rotate it 90deg to the right, scan, rotate ahead, scan, and then rotate 90 left, scan. It appears that I have to let it calibrate each time I enter to the loop to check for movement. Thanks for the help.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-13 23:12
    Hello,

    The PIR (as with any such device) is intended to remain still. Motion immediately causes the device to detect said activity and will trigger. Following that the settling time will be re-instated since everything the sensor sees will have changed dramatically.· Moving the sensor itself will only result in highly erratic readings.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.