-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathelectric-detect
More file actions
44 lines (39 loc) · 940 Bytes
/
electric-detect
File metadata and controls
44 lines (39 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
import RPi.GPIO as GPIO
import time
import subprocess
import sys
import os
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
x = 1
hours = 0
print("Will start in 10 seconds")
time.sleep(10)
def my_function():
os.system('clear')
global x
while True:
if GPIO.input(23):
print("We have elect")
x += 1
time.sleep(60)
else:
while True:
if not GPIO.input(23):
global hours
msg = "Elect Lost at Home " + str(hours) + " hours ago"
print(msg)
hours += 1
#subprocess.call(["/home/pi/bin/aprs-rf-msg", str(msg)])
print("sleeping for 1 hour")
time.sleep(3600)
else:
print("Elect Restored. send msg")
#subprocess.call(["/home/pi/bin/aprs-rf-msg", "Power RESTORED!!"])
time.sleep(10)
#subprocess.call(["/home/pi/bin/aprs-rf-msg", "Power RESTORED!!"])
time.sleep(10)
my_function()
my_function()
GPIO.cleanup()