-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurlclouds.py
More file actions
66 lines (46 loc) · 1.23 KB
/
Copy pathurlclouds.py
File metadata and controls
66 lines (46 loc) · 1.23 KB
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
import serial
import time
import astral
import requests
url = 'http://api.openweathermap.org/data/2.5/weather'
citySearch = input()
# print (citySearch)
params = {
'q': citySearch,
'APPID': 'f96e96e150fcb459ba5d539d3ec67689'
}
response = requests.get(url, params=params)
data = response.json()
weather_list = data['weather']
description = weather_list[0]['description']
print (description)
# print (weather_list)
temp = data['main']['temp'] - 272.15
clouds= data['clouds']['all']
humidity = data['main']['humidity']
# # print('The temp in {} is {}''.format(data['name'],temp))
print ('the temperature in ' + data ['name'] + ' is ' + str(temp))
print ( 'cloud coverage is ' + str(clouds))
print ( 'humidity is ' + str(humidity))
# # print '\n'.join(weather)
# # print( str(coordlon))
# # print( str(coordlat))
#
ArduinoSerial = serial.Serial('/dev/cu.usbmodem1411',9600)
time.sleep(2)
#
ArduinoSerial.write(b'str(humidity)')
if clouds > 30:
ArduinoSerial.write(b'0') #send 1
print ("blue")
time.sleep(1)
print ('cloudy')
elif clouds < 10: #if the value is 0
ArduinoSerial.write(b'1') #send 0
print ("orange")
time.sleep(1)
print ('sunny')
if clouds > 50:
print ('cloudy')
else:
print ('sunny')