fipy + PIR sensor

  • Hi,
    I have an expansion board 3.0 and a fipy that I have connected to a PIR sensor. The idea I have is to detect motion constantly where there is any motion. The PIR-sensor that I have works now but not exactly how I wanted it to. One of the issues that I have with it is that it cannot detect motion constantly. To test this I move my hands constantly before the sensor for like one minute, however it reports it has detected say, for five seconds and the it says no motion even though I am still waving my hands in front of it. What I want for it to do is to keep detecting motion as long as I am moving my hands and stop as soon as I stop waving. I have rotated the delay to max so now it detects every five seconds and sometimes every four seconds.
    In summary

    1. I want it to be able to keep detecting motion as long as there is motion and not stop detecting like after five seconds "no motion presence" while there is motion.
    pir = Pin(Pin.exp_board.G11,mode=Pin.IN, pull=Pin.PULL_UP)
    state = False
    while True:
      val = pir()
      #print('Value:', val)
      if state == False:
        if val == 1:
          state = True
          print("presence detected 1111111111111111111111111111111")
        if val == 0:
          state = False
          print("NO presence")

    I have windows 10, use atom pymakr.

    Thank you in advance

  • @Israel How did you know to connect your sensor to P4 ? (based on your photos).
    I am looking to connect my analog output from the sensor to Expansion Board 3.0 and wonder what pin to use on the Expansion Boar...

  • @jcaron Good to know that I cannot get rid of the annoying "quite time". because I spent a lot of time trying to disable it somehow. I will try with the other adjuster and will update you if I see any difference. I will see if I can check the voltage if I get any instrument to do it as I currently don't have any. With the pill up, I assume you mean the PULL_UP in my code.


    That will I change to PULL_DOWN and see what happens too, I have seen pull_down has been used in some projects too.

  • @Israel Uh, the delay it stays up should be a few seconds at the minimum value and minutes at the max (I don't remember exactly, but the max is at least 10 minutes, possibly quite a bit more).

    Are you sure you are adjusting the right potentiometer?

    Can you check voltage levels on your signal pin? Also, I'm not quite sure you need the pull up, though I used it in a different scenario so I can't say for sure.

    You cannot get rid of the quiet time on that PIR.

  • @jcaron Ok, I tired to put the jumper on re-trigger and also on single trigger as well as adjusted the time delay knob to find an appropriate delay. I tried combining these three adjustments multiple times. Through out this, the only difference I see is that the detection signal stays on longer. Like after the last detection it will continue reporting fake detection for extra nine to te seconds if I adjusted the delay-knob to the max and other wise will stay on for like five to six seconds and keep reporting fake detection as well. After that it will stay on the "quite mode" for a few seconds like between five and nine where it refuses to detect anything even if I wave my hand, like it doesn't keep detecting as long as I keep waving my hands too. The PIR-sensor that I have, does it have a quite-time too? And is there a way to disable it, because it seems very unnatural to me and annoying. The expansion board I use provides 5V so it is fine [ ]. The best way is to keep detecting as long as there is motion and stop when there isn't any and start again during another detection and so on, without any wired delay in between?

  • @Israel That looks like an HC-SR501. Set it to re-trigger, and configure the delay appropriately. The signal will go up when you start moving, will stay up for the configured delay, and that delay will be extended as long as you continue moving before the delay expires.

    Once the delay expires, the signal goes down, and there's a short period of a few seconds during which no detection will take place.

    Note that the HC-SR501 is designed to operate with a 5V source, while the Pycom stuff runs on 3.3V. You may experience issues with false negatives or positives.

  • The only configuration I have applied is I just rotated the time-delay sensitivity to low. I have also tested it in single and repeatable triggers using the "Trigger Mode Selection Jumper", it did not create any difference.
    The links lead to the pictures of my sensor.

  • @Israel You'll have to give more details about the sensor you use, and possibly it's settings and how you connected it.

    Note that many (most?) sensors have a "quiet time" after a detection during which they will not detect anything.

    Also, depending on the sensor, you may have a re-trigger mode which keeps the sensor output high as long as motion is detected.

Log in to reply

Pycom on Twitter