Skip to content

Commit

Permalink
event detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mubaraq Olayinka committed Jul 30, 2024
1 parent 830f0e7 commit 5522a8b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@
def on_motion_detected(channel):
print("Motion Detected!")
client.publish(MQTT_TOPIC, "Motion Detected")

# Add event detection on the PIR pin
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=on_motion_detected)

try:
print("PIR Module Test (CTRL+C to exit)")
time.sleep(2) # to stabilize sensor
print("Ready")


0 comments on commit 5522a8b

Please sign in to comment.