I’m trying to use a motion sensor with the Raspberry Pi but despite all the tutorials I followed, the input of the raspberry pi is always high.
Here is my code below. I used a LED to turn it on when movement is detected but I didn’t insert the code to do it yet. I’m trying first to make the motion sensor work.
I thought it was the sensors that didn’t work but I have tried with 3 different sensors so it might not be this. I checked all the connection too so it’s not the connection. The Raspberry Pi works fine with other projects so it’s not the Raspberry Pi. I don’t how to solve this. I spent almost 3 days trying to make it work.
Someone help me !
1code * (not “Image if my connections”, I wrote too fast sorry) – Menelik Nouvellon 6 hours ago
raspberrypi.stackexchange.com/questions/98371/… – tlfong01 6 hours ago
1DO NOT post pictures – post text! Without details of WHAT you have used and how it is CONNECTED the Question is meaningless. – Milliways 4 hours ago
Hi @Menelik Nouvellon, Welcome and nice to meet you. Ah, let me see. I quickly read twice your question’s three short paragraphs which describe succinctly what you have researched, the problem you encountered, your troubleshooting procedures, and your deduced conclusion, which I think is very reasonable. I have been answering perhaps more than twenty interesting questions like yours in the past two years. What is common in those interesting questions is what is reflected behind, the sorrow of problem solving newbies, … Ah, lunch time. See you later. Cheers. – tlfong01 4 hours ago
1ok I’ve made another post with the connections and the written code. I really need help ! – Menelik Nouvellon 3 hours ago
How come all my three PIRs are always on?
Because all of them are bad guys.
Try the smallest guys below. They are very good.
You might like to show your PIR and a schematic, like below.
You might also like to study the datasheet and make a summary for troubleshooting reference.
More details are in Appendix A. You need to know more details when testing and troubleshooting.
You might notice that the datasheet does not give the output voltage values for motion detect and motion not detected. What are given are current values IOH, IOL +-10mA, and corresponding VOH, VOL values (Yes, you need a have a basic idea of IOH, IOL, VOH, VOL). The reason is that PIRs are often placed far far away from Rpi, so outputting currents through a long wire, perhaps 20 meters, and causes a DC voltage drop across a resistance (Note 1) near the Rpi is the usual trick for the PIR application.
If you don’t have installed this current sensing resistor, you might have fake positives, I mean High signal, for ever.
I forgot to tell you how to check out the always High PIRs are bad guys. The trick is to use a rice bowl to cover up the bad guy. If the bad guy still says something is moving, of course he is lying.
(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
(5) AliExpress AM312 DC 2.7 to 12V Mini IR Pyroelectric Infrared PIR Motion Human Sensor Automatic Detector Module – US$1.29
(6) Pyroelectric Infrared Radial Sensor AM312 (DSP, Schmidtt) Manual – NanYang SenBa
(7) PIR Sensor Description and Technical Details – AdaFruit
(8) PIR Sensor Tutorial – AdaFruit
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 °
- 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.