Created
May 3, 2015 13:33
-
-
Save amenk/c61cf88698bfd555d8d8 to your computer and use it in GitHub Desktop.
Metrix Gaszähler -> Volkszähler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import time | |
from subprocess import call | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setwarnings(False) | |
# GPIO definieren | |
REED_gas = 3 # GPIO 3 (Pin 5) | |
GPIO.setup(REED_gas, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
status_alt=1 | |
while True: | |
status_aktuell = GPIO.input(REED_gas) | |
# REEDKONTAKT geoeffnet | |
if status_aktuell == 1: | |
#print "Kontakt offen" | |
status_alt=GPIO.input(REED_gas) | |
# REEDKONTAKT geschlossen | |
elif status_aktuell==0: | |
#print "Kontakt geschlossen" | |
if status_alt!=status_aktuell: | |
status_alt=GPIO.input(REED_gas) | |
print "Pulse" | |
call(['/var/www/volkszaehler.org/misc/tools/vzclient','-u','YOUR-UID-GOES_HERE','add','data','value=1','--url','http://localhost/middleware.php']) | |
time.sleep(0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment