version as running since 2015-04-05 noon

This commit is contained in:
telegnom 2015-04-05 16:40:30 +02:00
parent 101f78be57
commit 0c811dfd92
2 changed files with 15 additions and 9 deletions

View File

@ -42,14 +42,20 @@ def readgpio():
print("start readgpio mainloop") print("start readgpio mainloop")
while True: while True:
gpioevent = gpiopoll.poll() gpioevent = gpiopoll.poll()
gpio.read() gpioval = gpio.read(1)
gpio.seek(0) gpio.seek(0)
if gpioval == '0':
now = time.time() now = time.time()
if ((now-last) >= 0.2):
power = round(1800 / (now-last),2) power = round(1800 / (now-last),2)
if sys.stdout.isatty(): if sys.stdout.isatty():
print("Current power consumption: " + str(power) + " Watt") print("Current power consumption: " + str(power) + " Watt")
print(repr(gpioval))
powerqueue.put([now, power]) powerqueue.put([now, power])
last = now last = now
else:
if sys.stdout.isatty():
print("ERROR: not a falling edge! Ignoring interrupt")
if __name__ == "__main__": if __name__ == "__main__":
try: try:

View File

@ -6,8 +6,8 @@
# Required-Stop: $remote_fs $syslog # Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
# Default-Stop: 0 1 6 # Default-Stop: 0 1 6
# Short-Description: Put a short description of the service here # Short-Description: PowerPi - Logging electric energy consumption
# Description: Put a long description of the service here # Description: Logs the electric energy consumption in the hq with the power of a raspberry and a flying circus.
### END INIT INFO ### END INIT INFO
# Change the next 3 lines to suit where you install your script and what you want to call it # Change the next 3 lines to suit where you install your script and what you want to call it