Skip to content

Commit 51c45d3

Browse files
authored
Update README.md
1 parent b6aeb42 commit 51c45d3

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
11
# blynk-library-py
22

3-
## Work in progress...
3+
## Usage
4+
5+
```py
6+
import BlynkLib
7+
import time
8+
9+
BLYNK_AUTH = 'YourAuthToken'
10+
11+
# Initialize Blynk
12+
blynk = BlynkLib.Blynk(BLYNK_AUTH)
13+
14+
# Register Virtual Pins
15+
@blynk.VIRTUAL_WRITE(1)
16+
def my_write_handler(value):
17+
print('Current V1 value: {}'.format(value))
18+
19+
@blynk.VIRTUAL_READ(2)
20+
def my_read_handler():
21+
# this widget will show some time in seconds..
22+
blynk.virtual_write(2, time.ticks_ms() // 1000)
23+
24+
# Start Blynk (this call should never return)
25+
blynk.run()
26+
```
27+
28+
## Notes
29+
30+
For some diveces (like PyCom WiPy) you need to setup internet connection first:
31+
```py
32+
from network import WLAN
33+
34+
WIFI_SSID = 'YourWiFiNetwork'
35+
WIFI_AUTH = (WLAN.WPA2, 'YourWiFiPassword')
36+
37+
wlan = WLAN(mode=WLAN.STA)
38+
wlan.connect(WIFI_SSID, auth=WIFI_AUTH, timeout=5000)
39+
print(wlan.ifconfig())
40+
```

0 commit comments

Comments
 (0)