Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIR motion sensor code doesn't work well when using high timeout on the PIR device #173

Open
emlowe opened this issue Jan 13, 2025 · 3 comments

Comments

@emlowe
Copy link

emlowe commented Jan 13, 2025

I don't know if this is a documentation issue or a code issue. On my PIR sensor I can configure the timeout delay to be quite long (it might be broken but it seems like 60 mins or more). When set to this state, the PIR doesn't make any changes to the signal.

For example, the python code MotionSensor.py won't print anything (it just sits at pause) since it doesn't check the initial setting of the sensor - and since the signal may never change if there is motion, MotionSensor.py will never do anything at all - at least in my tests, the code will never trigger for as long as there is motion especially when the device is in H mode and with a high timeout set.

I think this could be fixed relatively simply by checking the initial state of the sensor - this would be straightforward in MotionSensor.py with the following before running pause:

if pir.motion_detected:
    motion()
else:
    no_motion()
pause()

I'm not sure if the node GPIO code works similarly or not - I also haven't tried yet using the new option for trigger, but I think this would happen regardless of trigger - in LH mode, you would still have to wait for the module timeout to trigger.

So I think this change would be useful - and or perhaps a recommendation to change the PIR timeout to be the minimum value as this module includes a built-in timer, so you don't need to use the PIR timer

@bugsounet
Copy link
Owner

maybe solved with #167 and will be available on next release soon

@emlowe
Copy link
Author

emlowe commented Jan 13, 2025

Possibly, but my sensor doesn't seem to retrigger signals when already set (regardless of H or LH trigger mode) - but I'll test it. But in any event having your PIR sensor with a timeout LONGER than the timeout set here in the module is probably not a useful setting combination

I think perhaps a mention in the documentation that your PIR h/w timeout should be less than your module config timeout would be helpful.

@emlowe
Copy link
Author

emlowe commented Jan 13, 2025

On my sensor, in H mode - the sensor simply keeps the line pulled HIGH and resets the timer - it doesn't actually cause the line to change, so code expected for signals won't get any signal since nothing on the line changes.

In LH mode, the sensor will always drop the line to LOW on timeout.

So in H mode, my sensor may never actually trigger a signal at all ever, if the line is already pulled High when the module starts, and while motion it will never go LOW. So I do think it might be important to check the state at start time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants