Can't connect to blynk.cloud:443, Error 202

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.

Can someone help me?

Hello @JimmyD. You use different BLYNK_AUTH token? Also is this an existing token?

@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())

or maybe try use some example, like

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.

Possibly yes, but I’m not sure that it is board issue. In any case, try to research the libraries, drivers needed for your board.

In case anyone else has this issue, I did figure it out.

For some reason, importing the SX1262 (LoRa chip) driver was conflicting with connecting to Blynk.

I found that if I structured my code so that I verified the Blynk connection was active before importing the driver code, everything worked fine.

First I defined a function to initialize and start LoRa receiving. Then I do not call that function until I know Blynk has started.

Now I am sending sensor data from a LoRa chip to a LoRa chip that is part of a dev board connected to my Wifi and Blynk. All works great!

2 Likes

Thanks for update. It’s perfect.