Question
PIR motion sensor always on and stays on. Why?
Answer
Part 1 - HC SR501 Analog Sensor - Not Recommended
This analog sensor is difficult to adjust sensitivity and delay time using the two little trim potentiometers. It is also be easility be interferenced by noises.
I googled to find that analog PIR sensors such as HC SR-501 have a noise problem.
Possible reasons include: forgot pullup/down resistor, too noisy (from microwave oven, induction cooker for example, cable too long, cable not shielded, power noise (due to power hungry BlueTooh, Wifi, solution is turn them off or heavily by pass/decouple Rpi USB)
After more experimentation, I concluded that analog sensors are not reliable, or too many false positive, or always on. A quick fix is switch to digital sensor such as AM312.
Part 2 - AM312 Digital Sensor - Highly Recommended
There is no sensitivity and time delay adjustment needed. The factory default settings are:
Delay time: 2 seconds;
Blocking time: 2 seconds;
Triggering method: repeatable
I found this digital PIR sensor very newbit friendly.
References
(1) Introduction to HC-SR501 A complete step by step tutorial on Introduction to HC-SR501
(2) TaoBao HC-SR501 PIR Sensor Module - ¥3.23
(3) TaoBao DC 12V Water Proof Smart PIR Sensor Module With Switch - ¥12.80
(4) TaoBao AM312 PIR Sensor ¥5.28
(6) Pyroelectric Infrared Radial Sensor AM312 (DSP, Schmidtt) Manual - NanYang SenBa
(7) PIR Sensor Description and Technical Details - AdaFruit
(8) PIR Sensor Tutorial - AdaFruit
Appendices
Appendix A - Pyroelectric Infrared Radial Sensor AM312 Specification
Working voltage: DC 2.7-12V;
Delay time: 2 seconds;
Blocking time: 2 seconds;
Triggering method: repeatable
Sensing range: ≤ 100 degrees cone angle, 3-5 meters; (according to the specific lens)
Operating temperature: -20 - +60 °
Features
Anti-interference enhancement, the internal use of digital signal processing, direct high-low output.
Repeatable triggering mode: If a cat moves in the sensing range during the delay period, and output is high, output will remain high until delay time after the cast has left, ie, the sensing module will automatically delay after detecting an activity of the cat, with the time of the last activity as the starting point of the delay time.
Appendix B - PIR devices