diff --git a/sensor.py b/sensor.py index ad208f4..02995c5 100644 --- a/sensor.py +++ b/sensor.py @@ -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") + +