hi.
There are some news about my Sensor problem.
i tried to install these steps according this link
https://teilzeitrebell.de/blog/magicmirror-part-2-bewegungsmelder
i made two sh-scripts for screen on & off
monitor_off.sh
monitor_on.sh
then i created this phyton
pir_loop.py
!/usr/bin/env python
import sys
import time
import RPi.GPIO as io
import subprocess
io.setmode(io.BCM)
SHUTOFF_DELAY = 10 # seconds
PIR_PIN = 17 # Pin 11 on the board
def main():
io.setup(PIR_PIN, io.IN)
turned_off = False
last_motion_time = time.time()
while True:
if io.input(PIR_PIN):
last_motion_time = time.time()
sys.stdout.flush()
if turned_off:
turned_off = False
turn_on()
else:
if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
turned_off = True
turn_off()
time.sleep(.1)
def turn_on():
subprocess.call("sh /home/pi/Pir-Sensor/monitor_on.sh", shell=True)
def turn_off():
subprocess.call("sh /home/pi/Pir-Sensor/monitor_off.sh", shell=True)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
io.cleanup()
i can start this with
python pir_loop.py
and it seems that it works.
But in the code i defined a delay of 10 seconds. But after it, it happend nothing.
the weird thing is, that the screen turn off after exact 2 minutes. If i move in front of the sensor the screen turn on again.
But if i do nothing or cover the sensor with something the screen turn on after exact one minute.
does anybody has an idea, whats wrong there?