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
Shared 55 years ago
191 views
Shared 55 years ago
89 views
Shared 55 years ago
403 views
Shared 55 years ago
75 views
Shared 55 years ago
356 views
Shared 55 years ago
2K views
Shared 55 years ago
4.1K views
Shared 55 years ago
2.3K views
Shared 55 years ago
1K views
Shared 55 years ago
47 views