This repository was archived by the owner on May 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 3232while not wifi .isconnected ():
3333 pass
3434
35- print ('IP: ' + wifi .ifconfig ()[0 ])
35+ print ('IP: ' , wifi .ifconfig ()[0 ])
3636
3737print ("Connecting to Blynk..." )
3838blynk = BlynkLib .Blynk (BLYNK_AUTH )
Original file line number Diff line number Diff line change 1010 Social networks: http://www.fb.com/blynkapp
1111 http://twitter.com/blynk_app
1212
13- This example shows how to initialize your PyCom board
13+ This example shows how to initialize your WiPy 1.0 board
1414and connect it to Blynk.
1515
1616Don't forget to change WIFI_SSID, WIFI_AUTH and BLYNK_AUTH ;)
1717"""
1818
1919import BlynkLib
2020from network import WLAN
21+ import machine
2122
2223WIFI_SSID = 'YourWiFiNetwork'
23- WIFI_AUTH = ( WLAN . WPA2 , 'YourWiFiPassword' )
24+ WIFI_PASS = 'YourWiFiPassword'
2425
2526BLYNK_AUTH = 'YourAuthToken'
2627
27- # Connect to WiFi
28+ print ( "Connecting to WiFi..." )
2829wifi = WLAN (mode = WLAN .STA )
29- wifi .connect (WIFI_SSID , auth = WIFI_AUTH )
30+ wifi .connect (ssid = WIFI_SSID , auth = ( WLAN . WPA2 , WIFI_PASS ) )
3031while not wifi .isconnected ():
3132 pass
3233
33- print (wifi .ifconfig ())
34+ print ('IP: ' , wifi .ifconfig ()[ 0 ] )
3435
35- # Initialize Blynk
36+ print ( "Connecting to Blynk..." )
3637blynk = BlynkLib .Blynk (BLYNK_AUTH )
3738
38- while True :
39- blynk .run ()
39+ @blynk .ON ("connected" )
40+ def blynk_connected (ping ):
41+ print ('Blynk ready. Ping:' , ping , 'ms' )
42+
43+ def runLoop ():
44+ while True :
45+ blynk .run ()
46+ machine .idle ()
47+
48+ # Run blynk in the main thread:
49+ runLoop ()
You can’t perform that action at this time.
0 commit comments