vshymanskyy / blynk-library-python

Blynk library for Python. Works with Python 2, Python 3, MicroPython.
https://blynk.io/
MIT License
281 stars 97 forks source link

disconnected after 30 seconds on ESP32 #17

Closed hznupeter closed 5 years ago

hznupeter commented 5 years ago

I uploaded the 02_virtual_read ,it will connect to Blynk app, but after 30 seconds ,it will disconnected. I have tried different boards ,but the same result.

hznupeter commented 5 years ago

Fix by:

it's need add

while True:
    blynk.run()
    pass

just like loop() in arduino

the Full code as below:

import network
import BlynkLib
import time
from mpython import *
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
  print('connecting to network...')
  wlan.connect('Xxxxi_0432', 'xxxxxxxxxxx') 
  while not wlan.isconnected():
    pass
print('network config:', wlan.ifconfig())
BLYNK_AUTH = 'e8d3214523d148a1beacc8022af2273b'
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
while True:
    blynk.run()
    pass
vshymanskyy commented 5 years ago

v0.2.0 is released and available via pip: https://github.com/vshymanskyy/blynk-library-python/releases/latest