Sub for Intelligence:
import RPi.GPIO as GPIO
import time
from twilio.rest import Client
# Twilio setup
account_sid = 'YOUR_ACCOUNT_SID'
auth_token = 'YOUR_AUTH_TOKEN'
client = Client(account_sid, auth_token)
twilio_number = '+1YOUR_TWILIO_NUMBER'
target_number = '+1TARGET_PHONE_NUMBER'
# GPIO setup
GPIO.setmode(GPIO.BCM)
PIR_PIN = 4 # GPIO pin connected to PIR sensor output
GPIO.setup(PIR_PIN, GPIO.IN)
def send_sms():
message = client.messages.create(
body="Motion detected! Get your ass up!",
from_=twilio_number,
to=target_number
)
print("SMS sent:", message.sid)
print("Starting motion sensor...")
try:
while True:
if GPIO.input(PIR_PIN):
print("Motion detected!")
send_sms()
time.sleep(10) # avoid spamming SMS, wait 10 seconds
time.sleep(1)
except KeyboardInterrupt:
print("Exiting program.")
finally:
GPIO.cleanup()
Email:edrhoad3@gmail.com