I’ve recently been having a lot of fun with Blynk and an ESP32 board. Now I have an ESP32 board with a LoRa chip on it so I can play with more project ideas.
For some reason I cannot connect to the Blynk server.
Board - Heltec LoRa32 V3
OS - Windows 10
Using Blynk 2.0
from sx1262 import SX1262
import time
import network
import machine
import ssd1306
from machine import Pin, I2C, ADC
from ssd1306 import SSD1306_I2C
import BlynkLib
#Wifi connect and Blynk
#----------------------------------------------------------------------------------------
WIFI_SSID = '*****'
WIFI_PASS = '*****'
BLYNK_AUTH = '*****'
wlan = network.WLAN(network.STA_IF) # create station interface
wlan.active(True) # activate the interface
wlan.isconnected()
time.sleep_ms(500)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('WIFI_SSID', 'WIFI_PASS')
time.sleep_ms(500)
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
#Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
#----------------------------------------------------------------------------------------
The error I get is below. Line 30 is referring to blynk = BlynkLib.Blynk(BLYNK_AUTH)
Everything worked perfectly fine with the other ESP32 board I was using and the mobile app I made using Blynk. Now I can’t connect to the Blynk server for some reason.
@Oleksii-QA There was an existing token that I’d been using. I figured that might have been the issue so I created a new Device in my console, thus generating a new token. That one didn’t work, either.
I found some similar issue, please try use something like that (add function):
def do_connect():
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('WIFI_SSID', 'WIFI_PASS')
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
I tried this and my connection to wifi seems to be fine. I even added a return value of what is below to ensure I was connected to wifi before trying to start Blynk. Still gives an error at the line where blynk is started.
def do_connect()
.
.
.
Connected = wlan.isconnected()
return Connected
Connected = do_Connect()
if Connected:
#connect to Blynk
Just tried with my other ESP32 board (that one doesn’t have the LoRa chip) and everything still worked perfectly.
Could the LoRa chip (SX1262) that is on this ESP32 dev kit be causing some sort of issue with connecting to Blynk? I can’t imagine it would.