Syntax Error on #define BLYNK_TEMPLATE_ID when running any script

I am new to Blynk - I have been searching a way around this issue - which I may have triggered myself? -:

node terminal.index.js 


SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:760:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11

Hardware model: RPiZeroW
Communication type: Wifi
Smartphone OS Android
Blynk server (cloud)
Blynk Library version
node -v :v11.15.0
npm -v : 7.20.5
asmv-module@1.0.0 /home/pi/asmv-module
├── blynk-library@0.5.4
└── onoff@6.0.3

I have declared all virtual pin, created my template, etc…
I tried to run the Terminal example from Blynk Examples

Any idea what I am doing wrong ?

ps: tried the blynk-client Auth but I need TCP, it is nt going through and same issue with TCP script it triggers a syntax error.
pps: packages were installed global -g and then created the project directory and npm init the project directory and requested blynk and onoff package locally in project directory.


  You can send/receive any data using WidgetTerminal object.

  App project setup:
    Terminal widget attached to Virtual Pin V1

// Template ID and Device Name are provided by the Blynk.Cloud.
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLOPZp_sO3"
#define BLYNK_DEVICE_NAME           "ASMV 001"

// Comment this out to disable prints and save space
#define BLYNK_PRINT stdout

 #include <BlynkApiWiringPi.h>
 #include <BlynkApiLinux.h>
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);
#include <BlynkWidgets.h>

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget

  // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
  if (String("Marco") == param.asStr()) {
    terminal.println("You said: 'Marco'") ;
    terminal.println("I said: 'Polo'") ;
  } else {

    // Send it back
    terminal.print("You said:");
    terminal.write(param.getBuffer(), param.getLength());

  // Ensure everything is sent

void setup()
  // Clear the terminal content

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println(F("Type 'Marco' and get a reply, or type"));
  terminal.println(F("anything else and get it printed back."));

void loop()

int main(int argc, char* argv[])
  const char *auth, *serv;
  uint16_t port;
  parse_options(argc, argv, auth, serv, port);

  Blynk.begin(auth, serv, port);

  while(true) {

  return 0;



    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\

  Give Blynk a Github star! =>

OnOff mode
Connecting to: 443
SSL authorization...
SSL not authorized

use triple backticks or else pete sir will remove it

You’re combining new Blynk version 2 with Blynk Legacy (version 1) code and als using old Legacy Blynk library.

Hi bazzio,
I am new. ok I can of understood that Blynk has changed somehow - albeit unclear for me.
And I guess I need to use version 2 code ?
Are the not Blynk version 2 or are they version 1?
where to find version 2 samples?

Hi, you can find the latest version of the library at the link - Releases · blynkkk/blynk-library · GitHub,
and examples from the link - blynk-library/examples at master · blynkkk/blynk-library · GitHub

And documentation:

@rfv-370 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:


Hi Pete,
I thought I did… does it not display correctly

Hi DimitryPB,
thank you. So if I understand well the
├── blynk-library@0.5.4
└── onoff@6.0.3
will not work with the new cloud Blynk, is this correct?

But npm does not provide any newer librairy of blynk to install…
when checking - I do have the latest available from node.js .

Any work around to force the upgrade with node.js npm ?

and/or is blynk-library@0.5.4 works with the new Blyn cloud server at all?

Further I looked at
[Prepare Your Code - Blynk Documentation]
but nothing about Raspberry P…i and the link for library installation is inactivated:

And here as well nothing on how to install the new libarary :slight_smile:

Any idea on how to have the new blynk on the raspberry pi?

Or with RaspberryPi we need to revet to the old ?

It does now.


For all Newbies on Blynk with a Raspberry Pi ( Rpi ):
There are 2 Blynk (s):
The old Blynk , and
The New Blynk - - which is referred to as " Blynk 2.0 " or Blynk 2
The new Blynk is (Blynk 2.0) - which has its own IOS/Android App as well as a web interface which you need to signup
The old Blynk is with its own (different) App IOS/Android.

  • I know for a newbie it can be confusing… it was for me…-

Just take note that the old Blynk ( might be discontinued (my understanding?) and that new Blynk 2 is not yet working on Raspberry Pi ( RPi) with node.js (my experience).

The only way for now - August 2021 - to have a Raspberry Pi to connect to Blynk 2 ( is to use the Python Library according the forum :

I hope it will help others with Rapsberry Pi s in case you need.

This thread can be closed I guess. - or updated with a date of availability of the node.js / npm availability of the blynk-library (2.0) updates… @BlynkTeam ?

@rfv-370 I think you might have confused things further!

Old Blynk
Known as Blynk Legacy or Blynk 0.1
Not developed for over 2 years and no longer supported.
New sign-ups to Blynk Legacy will probably be stopped in the future and the system will be retired evebtually.

New Blynk
Known as Blynk IoT or Blynk 2.0
Both and will take you to the Blynk IoT website where you can sign-up for an account.

Personally, I don’t like the RPI as a Blynk client. It’s expensive, slow to boot, requires a beefy power supply, needs the OS installing and updating regularly and is prone to SD card failures.
You’re generally much better off with a NodeMCU or ESP32 as your Blynk client device and using C++ as your programming language (most of the examples are in C++ because this is the route most people take).

If you do use an RPI then its probably better to do what I do.
I use NodeMCU and ESP32 clients running non-Blynk code, communicating with an RPI running Node-Red.
Communication is via MQTT and the RPI runs a Mosquitto MQTT broker. A Node-Red plug-in is used to talk to Blynk, giving the mobile app capability.
If you wanted to use the same RPI as a client then I guess you could do this in Node-Red, without any Blynk client library, by using the Node-Red RPI GPIO in/out nodes within Node-Red.



Thank you for your help to clarify things.

The node-red plugin you mentionned, is it this one ?

This node-red plugin is Blynk 2 compatible?

If so, you are right from node-red to blynk to mobile App. This would be nice.


No, that’s the legacy one.

The Blynk IoT one is called node-red-contrib-blynk-iot


I guess I got it:

You should read this, to better understand what works and what doesn’t in this new contrib…