How to fix compiler problem - #error “Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME”

I see posts from people who are experiencing the compiler error that says:
#error “Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME”

There are three possible causes for this error…

  1. The lines of code that specify the BLYNK_TEMPLATE_ID BLYNK_TEMPLATE_NAME are commented-out with double forwarded slashes (//) that turn these lines into comments rather than lines of code, like this….
/* Fill in information from Blynk Device Info here */
//#define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
//#define BLYNK_TEMPLATE_NAME         "Device"
//#define BLYNK_AUTH_TOKEN            "YourAuthToken"

Replace the commented-out lines of code with the two or three lines of Firmware configuration from your template or device screen, depending on whether you are using Blynk Edgent or static provisioning.

  1. You are using a version of the Blynk library which requires the lines of code that specify the BLYNK_TEMPLATE_ID BLYNK_TEMPLATE_NAME to be at the very top of your sketch.
    The Firmware Configuration screens all explain that the two or three lines of Firmware Configuration code should be AT THE VERY TOP of your sketch.
    You should ensure that you are using the latest version of the Blynk library and that your two or three lines of firmware configuration are at the very top of your sketch.

  2. You are using an older format of sketch with a newer version of the Blynk library. Earlier versions of the Blynk library used BLYNK_DEVICE_NAME rather than BLYNK_TEMPLATE_NAME. If you have BLYNK_DEVICE_NAME in your sketch then simply change it to BLYNK_TEMPLATE_NAME

Other common Mistakes

There are a few other common mistakes that people make, especially in relation to the Auth Token.

When using Blynk Edgent, there will be only two lines of Firmware Configuration code, which are copied from the TEMPLATE screen…

So with Edgent thee is no BLYNK_AUTH_TOKEN, as this is assigned dynamically when the device is provisioned via the app.

If you aren’t using Edgent then there will be three lines of Firmware Configuration code, which are copied from the DEVICE screen…

You’ll see that this includes a value called BLYNK_AUTH_TOKEN

Many old sketches used a variable called “auth” to store the Auth token and the most efficient way to convert an old sketch into the new format is to delete everything that relates to theirs Auth variable use BLYNK_AUTH_TOKEN directly in your Blynk.begin() or Blynk.config() statement, like this….

Blynk.begin(BLYNK_AUTH_TOKEN, SSID, pass);

or…

Blynk.config(BLYNK_AUTH_TOKEN);

Pete.

1 Like