Hanging up at Blynk.begin()

I’m trying a very basic test with Blynk 2.0 and an ESP32 in Platform IO. I have no problems connecting this ESP32 to my WiFi network under other circumstances, but it just hangs at the Blynk.begin() command. I’m at a loss here.


platform = espressif32
board = esp32dev
framework = arduino
lib_deps = blynkkk/Blynk@^1.0.1


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"

char auth[] =  BLYNK_AUTH_TOKEN;
char ssid[] = "xxx";
char pass[] = "xxx";

void setup() {
  // establish serial comms ...
  while(!Serial) {;}                // wait for connection

  Blynk.begin(auth, ssid, pass);
  Serial.print("Blynk connected?: "); Serial.println(Blynk.connected());

void loop() {

Your template ID and device name need to be at the very top of your code.

Otherwise the Blynk library will see the sketch as a Legacy sketch and try to connect your device to the Legacy servers and that will fail with an Invalid Auth token error.


1 Like

That did the trick. Thanks for the explanation. In the legacy version of Blynk, I was able to move all of my Blynk-related function definitions into a separate .cpp file as long as it contained the appropriate include statement, for example:

#include <BlynkSimpleEsp8266.h>

Unless there is something else I’m missing, this no longer appears to be the case. Instead, it seems that I need to place the include statement with the template ID and device name definitions at the top of the main.cpp file.



1 Like