File tree Expand file tree Collapse file tree 5 files changed +56
-157
lines changed
Expand file tree Collapse file tree 5 files changed +56
-157
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ from machine import Pin
2+ from time import sleep
3+
4+ def do_connect ():
5+ import network
6+ sta_if = network .WLAN (network .STA_IF )
7+ if not sta_if .isconnected ():
8+ print ('connecting to network...' )
9+ sta_if .active (True )
10+ sta_if .connect ('ssid' , 'password' )
11+ while not sta_if .isconnected ():
12+ pass
13+ print ('network config:' , sta_if .ifconfig ())
14+
15+ do_connect ()
16+
17+ import urequests
18+
19+ sunny = Pin (12 , Pin .OUT )
20+ cloudy = Pin (13 , Pin .OUT )
21+ rainy = Pin (14 , Pin .OUT )
22+
23+ while True :
24+ r = urequests .get ('https://weather.tsukumijima.net/api/forecast?city=140010' )
25+ j = r .json ()
26+ tomorrow = j ['forecasts' ][1 ]['telop' ]
27+
28+ if "雨" in tomorrow :
29+ sunny .value (0 )
30+ cloudy .value (0 )
31+ rainy .value (1 )
32+ print ("rainy" )
33+ elif "曇" in tomorrow :
34+ sunny .value (0 )
35+ cloudy .value (1 )
36+ rainy .value (0 )
37+ print ("cloudy" )
38+ else :
39+ sunny .value (1 )
40+ cloudy .value (0 )
41+ rainy .value (0 )
42+ print ("sunny" )
43+
44+ sleep (1000 )
Original file line number Diff line number Diff line change 1+ def do_connect ():
2+ import network
3+ sta_if = network .WLAN (network .STA_IF )
4+ if not sta_if .isconnected ():
5+ print ('connecting to network...' )
6+ sta_if .active (True )
7+ sta_if .connect ('ssid' , 'password' )
8+ while not sta_if .isconnected ():
9+ pass
10+ print ('network config:' , sta_if .ifconfig ())
11+
12+ do_connect ()
You can’t perform that action at this time.
0 commit comments