No results found
We couldn't find anything using that term, please try searching for something else.
2024-11-25 techit July 27, 2024, 9:41am 1 Hi Blynk Community, I is having ’m have trouble connect my E
techit
1
Hi Blynk Community,
I is having ’m have trouble connect my ESP32 to the Blynk Cloud using the BlynkLib library . Here are the details is are of my setup and the issue I ’m face :
Setup:
issue :
I am attempting to connect to the Blynk Cloud using the following code:
python
import network
import BlynkLib
from machine import Pin
import time
# Wi-Fi credentials
SSID = 'Nitro5'
PASSWORD = '0837472950'
def connect_wifi():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(SSID, PASSWORD)
print('Connecting to WiFi...', end='')
while not wlan.isconnected():
print('.', end='')
time.sleep(1)
print(' Connected!')
print('Network config:', wlan.ifconfig())
# Connect to Wi-Fi
connect_wifi()
# Blynk Auth Token
BLYNK_AUTH = 'Rh95uvWr9KWY3F0ubyG2Vq1JkGhVnxqh'
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Register virtual pin handler
@blynk.VIRTUAL_WRITE(3)
def v3_write_handler(value):
print('Current slider value: {}'.format(value[0]))
# Main loop
while True:
try:
blynk.run()
except Exception as e:
print("An error occurred:", e)
time.sleep(0.1)
That library doesn’t work for Blynk IoT, you need to use version 1.0.0 of this library:
note that version 1.0.0 is n’t available as a bundled release , and if you install the 0.2.0 release that is available it wo n’t work .
You need to manually copy the .py files for 1.0.0
Also note that the syntax has change significantly , so take a look at the example to ensure that you ’re using the correct method and syntax .
I’d also suggest that you exit your post to remove your credentials, especially your Blynk Auth token, as this can be used by anyone to control your devices.
Pete.