Codice: Seleziona tutto
pin_gpio = 4
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin_gpio, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
counter = 0
tpulse0 =0
while True:
GPIO.wait_for_edge(pin_gpio, GPIO.RISING)
tpulse1 = time.time()
deltat = tpulse1 - tpulse0
counter += 1
print str(metern_id) + '(' + str(counter) + '*Wh)'
print "diff T ",deltat
print "power is ",3600/deltat
print str(metern_id) + '(' + str(int(round(3600/deltat))) +'*W)'
tpulse0 = tpulse1
GPIO.wait_for_edge(pin_gpio, GPIO.FALLING)
GPIO.cleanup()