-
Notifications
You must be signed in to change notification settings - Fork 1
/
Medicine_tray.py
104 lines (96 loc) · 3.51 KB
/
Medicine_tray.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import httplib, urllib, requests
from time import sleep
import RPi.GPIO as GPIO
import time
import string
GPIO.setmode(GPIO.BOARD)
def main():
while True:
baseURL = 'https://api.thingspeak.com/channels/458530/feeds.json?api_key=NUYNHP2VGDNTVWAT&results=2' # xxxx = your channel id
f = requests.get(baseURL)
m=eval(f.text) #get data from url
m=m['feeds'][1]['field1']
print(m)
if m == '1':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/0')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 1 Delivered")
elif m == '2':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/1')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 2 Delivered")
elif m == '3':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/2')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 3 Delivered")
elif m == '4':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/3')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 4 Delivered")
elif m == '5':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/4')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 5 Delivered")
elif m == '6':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/5')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 6 Delivered")
elif m == '7':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/6')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 7 Delivered")
elif m == '8':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/7')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 8 Delivered")
elif m == '9':
requests.get('127.0.0.1:5050/start')
print("Medicine Robot Started")
requests.get('127.0.0.1:5050/ledon/8')
print("Medicine LED Started")
requests.get('127.0.0.1:5050/stop')
#GPIO.output(11, GPIO.HIGH) # led 1 off
print("Medicine 9 Delivered")
else:
print ("not found command")
print '==========================================='
f.close()
sleep(5)
req="https://api.thingspeak.com/update?api_key=N0ETSMWMUHMQRLTY&field1=0"
requests.get(req)
if __name__ == "__main__":
main()