Bewegungssensor
Erscheinungsbild
import time
import RPi.GPIO as io
import httplib, urllib
io.setmode(io.BCM)
door_pin = 23
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(10, GPIO.OUT)
io.setup(door_pin, io.IN, pull_up_down=io.PUD_UP) # activate input with PullUp
while True:
if io.input(door_pin):
# Application specific variables
application_token = "aDhLdifpd6aTkuuPjLAjYS19hYtQPU"
user_token = "uqsV4ZLmM8q7FjgtbjzyXrUZHheLdx"
# Message specific variables
title = "Allert"
message = "im Haus ist jehmand"
url = "http://michaelhleonard.com/blog"
# To remove any of these fields you will need to remove them
# from the conn.request() below
# Start your connection with the Pushover API server
conn = httplib.HTTPSConnection("api.pushover.net:443")
# Send a POST request in urlencoded json
conn.request("POST", "/1/messages.json",
urllib.urlencode({
"token": application_token,
"user": user_token,
"title": title,
"message": message,
"url": url,
}), { "Content-type": "application/x-www-form-urlencoded" })
# Listen for any error messages or other responses
conn.getresponse()
print ('Gong')
GPIO.output(10, True)
time.sleep(3)
GPIO.output(10, False)