I am working with a surveillance camera project with a motion sensor and a buzzer on Raspberry Pi, but when I run the code below:
from gpiozero import MotionSensor
from gpiozero import Buzzer
from picamera import PiCamera
from datetime import datetime
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode (GPIO.BCM)
buzzer_pin = 24
led_pin = 18
GPIO.setup (24, GPIO.OUT)
GPIO.setup (18, GPIO.OUT)
camera = PiCamera()
pir = MotionSensor (4)
while True:
pir.wait_for_motion()
filename = datetime.now().strftime("%Y-%m-%d_%H.%M.%S.h264")
camera.start_recording(filename)
GPIO.output (buzzer_pin, True)
GPIO.output (led_pin, True)
sleep(1)
GPIO.output (buzzer_pin, False)
pir.wait_for_no_motion(filename)
GPIO.output (led_pin, False)
GPIO.output (buzzer_pin, True)
sleep(1)
GPIO.output (buzzer_pin, False)
camera.stop_recording()
I get the follwoing output:
Traceback (most recent call last):
File "/home/fisher/Motion_sensor.py", line 22, in <module>
pir.wait_for_no_motion(filename)
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 192, in wait_for_inactive
return self._inactive_event.wait(timeout)
TypeError: unorderable types: str() > int()
When the motion is detected, and the camera keeps recording until I remove the video file.
Any idea how to fix it? Thanks.
pir.wait_for_no_motion(int(filename))
@KarrarSavior – scitronboy Mar 27 '18 at 17:25