Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME

6.2k Views Asked by At

in this case i want to make a dust monitoring projet with Blynk connection. But when i integrated my program code with blynk template code, i meet some error : #error "Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME"

In this case im very confused, I had declared BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME at the beginning of the program like the following snippet of my program code:

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

#define BLYNK_TEMPLATE_ID "xxxxxxx"
#define BLYNK_TEMPLATE_NAME "xxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxx"

But the error says, i must to defined the BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME. How supposed i do in this case? Thank you

In this case i already try to downgrade my Blynk library from 1.3.0 to 1.2.0, and the problem BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME error was solved. But with Blynk 1.2.0 libraries my ESP-32 cannot connect to Blynk Cloud.

If i upgrade my Blynk Library to 1.3.0 again, the problem comes again.

3

There are 3 best solutions below

1
Tomáš Zato On BEST ANSWER

tldr: Put your #define BEFORE any Blynk headers

#include will essentially "copy-paste" the file you're including at the place you have the include. So if the Blynk library has this in one of the headers:

#ifndef BLYNK_TEMPLATE_ID
#error "Please specify id"
#endif

and you define the BLYNK_TEMPLATE_ID later, it will not compile, because at the compilation, the full code will look like this:

// from Blynk.h
#ifndef BLYNK_TEMPLATE_ID
#error "Please specify id"
#endif
// Blynk.h end
#define BLYNK_TEMPLATE_ID "xxxxxxx"
#define BLYNK_TEMPLATE_NAME "xxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxx"

Since the check is before the #define, it will not compile. Also, since this is an auth token, you probably should not define it in code. Instead, you can pass parameter to the compiler to set #define that will apply for the entire compilation.

1
Gerd Lissewski On

I have change in Code the name of "#define BLYNK_TEMPLATE_NAME "xxxxxxx"", in BLYNK Version 1.2 no problem. In version 1.3 you receive an error.

0
Quintrex One On

Put the #include of the Blynk Library, AFTER #defines of your 3 Blynk variables, BLYNK_AUTH_TOKEN BLYNK_TEMPLATE_NAME and BLYNK_AUTH_TOKEN. e.g

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID           "TMPL?????-u"
#define BLYNK_TEMPLATE_NAME         "ESP32DHT11"
#define BLYNK_AUTH_TOKEN            "LmnKOfjfkesoknjjjdtrash"

THEN!!    #include <BlynkSimpleEsp32.h>

good luck - Keith