Mein Bewegungsmelder/PIR HC-SR501 wird offenbar nicht von meinem Raspbian erkannt...
Laut diesem Guide muss man den PIR nur an 5V, GRD und einem GPIO stecken.
Ich habe mich deswegen für 5V (Pin 2), GND (Pin 20) und GPIO 11 (Pin 23) entschieden.
Ich habe die Positionen der GPIO von diesen Dokument.
Wenn ich jetzt die Skripte durchlaufen lasse, passiert einfach gar nichts ... egal was ich mache. Ich hab Sx (Empfindlichkeit) gerade ganz nach links gedreht, aber auch ganz nach rechts und in der Mitte getestet. Den Tx (Frequenz) hab ich gerade ganz rechts, doch ebenfalls in allen Lagen getestet.
Anfangs habe ich es mit verschiedenen, fertigen Skripts versucht. Bspw.
#!/usr/bin/python
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#|R|a|s|p|b|e|r|r|y|P|i|-|S|p|y|.|c|o|.|u|k|
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
# pir_1.py
# Detect movement using a PIR module
#
# Author : Matt Hawkins
# Date : 21/01/2013
# Import required Python libraries
import RPi.GPIO as GPIO
import time
# Use BCM GPIO references
# instead of physical pin numbers
#GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
# Define GPIO to use on Pi
GPIO_PIR = 11
print "PIR Module Test (CTRL-C to exit)"
# Set pin as input
GPIO.setup(GPIO_PIR,GPIO.IN) # Echo
Current_State = 0
Previous_State = 0
try:
print "Waiting for PIR to settle ..."
# Loop until PIR output is 0
while GPIO.input(GPIO_PIR)==1:
Current_State = 0
print " Ready"
# Loop until users quits with CTRL-C
while True :
# Read PIR state
Current_State = GPIO.input(GPIO_PIR)
if Current_State==1 and Previous_State==0:
# PIR is triggered
print " Motion detected!"
# Record previous state
Previous_State=1
elif Current_State==0 and Previous_State==1:
# PIR has returned to ready state
print " Ready"
# Loop until users quits with CTRL-C
while True :
# Read PIR state
Current_State = GPIO.input(GPIO_PIR)
if Current_State==1 and Previous_State==0:
# PIR is triggered
print " Motion detected!"
# Record previous state
Previous_State=1
elif Current_State==0 and Previous_State==1:
# PIR has returned to ready state
print " Ready"
Previous_State=0
# Wait for 10 milliseconds
time.sleep(0.01)
except KeyboardInterrupt:
print " Quit"
# Reset GPIO settings
GPIO.cleanup()
Alles anzeigen
oder
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
PIR_PIN = 11
GPIO.setup(PIR_PIN, GPIO.IN)
def MOTION(PIR_PIN):
print "Motion Detected!"
print("PIR Module Test (CTRL+C to exit)")
time.sleep(2)
print "Ready"
try:
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)
while 1:
time.sleep(100)
except KeyboardInterrupt:
print " Quit"
GPIO.cleanup()
Alles anzeigen
Aus diesen Skripten wurd klar, dass ich eigentlich nur in Python
1. RPi.GPIO importieren muss und daraufhin
2. GPIO.setmode(GPIO.BCM)
3. GPIO.setup(11, PGIO.IN)
4. GPIO.input(11)
machen muss, um das auszulesen. Egal wie ich davor herumfuchtel, ist hier jedoch leider immer eine 0
Kann mir jemand bei der Diagnose des Problems behilflich sein?