Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit 7596d23

Browse files
committed
Update hardware examples
1 parent 96f8f7b commit 7596d23

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

examples/hardware/ESP8266_ESP32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
while not wifi.isconnected():
3333
pass
3434

35-
print('IP: ' + wifi.ifconfig()[0])
35+
print('IP: ', wifi.ifconfig()[0])
3636

3737
print("Connecting to Blynk...")
3838
blynk = BlynkLib.Blynk(BLYNK_AUTH)

examples/hardware/PyCom_WiPy.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,40 @@
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
1414
and connect it to Blynk.
1515
1616
Don't forget to change WIFI_SSID, WIFI_AUTH and BLYNK_AUTH ;)
1717
"""
1818

1919
import BlynkLib
2020
from network import WLAN
21+
import machine
2122

2223
WIFI_SSID = 'YourWiFiNetwork'
23-
WIFI_AUTH = (WLAN.WPA2, 'YourWiFiPassword')
24+
WIFI_PASS = 'YourWiFiPassword'
2425

2526
BLYNK_AUTH = 'YourAuthToken'
2627

27-
# Connect to WiFi
28+
print("Connecting to WiFi...")
2829
wifi = WLAN(mode=WLAN.STA)
29-
wifi.connect(WIFI_SSID, auth=WIFI_AUTH)
30+
wifi.connect(ssid=WIFI_SSID, auth=(WLAN.WPA2, WIFI_PASS))
3031
while 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...")
3637
blynk = 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()

0 commit comments

Comments
 (0)