PIR Senor Test
I have some problems to install the pir sensor to send the monitior to sleep.
I don´t know, if my sensor is working correct. Has anybody a tutorial, how to connect the pir right and to test the function?
I think I connect everything right, but it doesn´t work.
I thought the same for a long time using the because I didnt have a breadboard. I went with the PIR Setup on the raspberry pi website. Managed to use this code to see that it works. You will need gpiozero to run it. Open Python 3. File > New. Paste this code in.
from gpiozero import MotionSensor import os pir = MotionSensor(4) #4 is the Pin? while True: if pir.wait_for_motion(timeout=10*60): #10 * 60 Seconds os.system("/opt/vc/bin/tvservice -p") else: os.system("/opt/vc/bin/tvservice -o")
You can if you want edit
to test if your PIR Sensor is working ok. After changing it, save it and press Ctrl + F5 to run the code. It will then spam up with motion detect or undetected depending on what you’ve changed.
Thanks! It works finde