-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.txt
164 lines (107 loc) · 3.46 KB
/
info.txt
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
user admin
pass
blank
wpa_supplicant location:
/data/etc/wpa_supplicant.conf
content must be:
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="mynet"
psk="mynet1234"
}
/data/etc/python
http://192.168.0.23/
curl http://localhost:7999/1/config/set?emulate_motion=1
curl http://localhost:7999/1/config/set?emulate_motion=0
TakePic.py
import commands
status, output = commands.getstatusoutput("curl http://localhost:7999/1/config/set?emulate_motion=1")
status, output = commands.getstatusoutput("curl http://localhost:7999/1/config/set?emulate_motion=0")
/data/etc/python/PIRDetector.py
PIRSensor.py
import commands
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
PIR = 12
RedLed = 11
GreenLed = 7
oldValue = 0
GPIO.setup(PIR, GPIO.IN) #Read output from PIR motion sensor
GPIO.setup(RedLed, GPIO.OUT) #LED output pin
GPIO.setup(GreenLed, GPIO.OUT) #LED ouput pin
GPIO.output(RedLed,0)
GPIO.output(GreenLed,0)
GPIO.output(RedLed,1)
time.sleep(0.2)
GPIO.output(RedLed,0)
time.sleep(0.2)
GPIO.output(GreenLed,1)
time.sleep(0.2)
GPIO.output(GreenLed,0)
time.sleep(0.2)
GPIO.output(RedLed,1)
time.sleep(0.2)
GPIO.output(RedLed,0)
time.sleep(0.2)
GPIO.output(GreenLed,1)
time.sleep(0.2)
GPIO.output(GreenLed,0)
time.sleep(0.2)
GPIO.output(GreenLed,1)
try:
while True:
i=GPIO.input(PIR)
if oldValue == i:
time.sleep(0.1)
else:
if i==0:
print "No intruders",i
time.sleep(0.1)
elif i==1:
print "Intruder detected",i
GPIO.output(RedLed,1)
GPIO.output(GreenLed,0)
status, output = commands.getstatusoutput("curl http://localhost:7999/1/config/set?emulate_motion=1")
status, output = commands.getstatusoutput("curl http://localhost:7999/1/config/set?emulate_motion=0")
time.sleep(3)
GPIO.output(RedLed,0)
GPIO.output(GreenLed,1)
print "Finished"
except Exception, e:
print e
except:
GPIO.cleanup()
PushBullet.py
import commands
token = "o.VLqvOeGm81DKI5OT3LwrZpMh3menh8NA"
msg = "Movimiento detectado por sensor"
URL =token + ': https://api.pushbullet.com/v2/pushes -d type=note -d title="Movimiento detectado" -d body="'+msg+'"'
command = "curl --header 'Access-Token:"+token+"' https://api.pushbullet.com/v2/pushes -d type=note -d title='Movimiento detectado' -d body='"+msg+"'"
status, output = commands.getstatusoutput(command)
status, output = commands.getstatusoutput("curl http://localhost:7999/1/config/set?emulate_motion=1")
PushIP.py
import commands
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
myIP = s.getsockname()[0]
s.close()
token = "o.VLqvOeGm81DKI5OT3LwrZpMh3menh8NA"
msg = "Mi IP es "+myIP
URL =token + ': https://api.pushbullet.com/v2/pushes -d type=note -d title="Sistema connectado" -d body="'+msg+'"'
command = "curl --header 'Access-Token:"+token+"' https://api.pushbullet.com/v2/pushes -d type=note -d title='Movimiento detectado' -d body='"+msg+"'"
status, output = commands.getstatusoutput(command)
status, output = commands.getstatusoutput("curl http://localhost:7999/1/config/set?emulate_motion=1")
To setup the pushbullet thingy:
LOGIN AS ADMING !!!
go to motion notification
turn on Run A Command
Command : python /data/etc/python/PushBullet.py
To start PIR sensor from the beginning:
create this file:
nano /data/etc/userinit.sh
enter this line:
python /data/etc/python/PIRSensor.py &