Hello,
I am new to Blynk - I have been searching a way around this issue - which I may have triggered myself? -:
node terminal.index.js
/home/pi/asmv-module/terminal.index.js:11
#define BLYNK_TEMPLATE_ID "TMPLOPZp_sO3"
^
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"
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Comment this out to disable prints and save space
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
#include <BlynkApiWiringPi.h>
#else
#include <BlynkApiLinux.h>
#endif
#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
BLYNK_WRITE(V1)
{
// 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());
terminal.println();
}
// Ensure everything is sent
terminal.flush();
}
void setup()
{
// Clear the terminal content
terminal.clear();
// 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("-------------"));
terminal.println(F("Type 'Marco' and get a reply, or type"));
terminal.println(F("anything else and get it printed back."));
terminal.flush();
}
void loop()
{
Blynk.run();
}
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);
setup();
while(true) {
loop();
}
return 0;
}
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 https://examples.blynk.cc/ not Blynk version 2 or are they version 1?
where to find version 2 samples?
@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:
```
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.io (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 Blynk.cc. 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 (blync.cc) might be discontinued (my understanding?) and that new Blynk 2 is not yet working on Raspberry Pi ( RPi) with node.js (my experience).
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 Blynk.cc and Blynk.io 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.