BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk in local server on Pi....have tried for the last 2 days and still cant find what is wrong

Using Raspberry Pi Zero W + Iphone and trying to move succesfull blynk control with index.js from global to local server ( I followed Anna’s instructions :stuck_out_tongue:) …trying for 2 days and still cant figure what is wrong…Here is what I am doing…Please help…

For global server it works fine…I open 1 terminal window and type
export PATH=$PATH:/opt/nodejs/bin/
unset NODE_PATH
blynk-client ‘codeforglobalserver’

Then I open a second terminal window and type node index.js. It works fine…click button and led changes…

Then close both terminal windows, open a new terminal window to launch local server and type:
java -jar server-0.41.13-java8.jar -dataFolder /home/pi/Blynk

Then open a second terminal window, edit index.js as below

From:
var AUTH = ‘codeforglobalserver’;
var blynk = new Blynk.Blynk(AUTH);
To:
var AUTH = ‘codeforLOCALserver’;
var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr:”192.168.1.14”, port:8080 } ) });

I get the error message below:

/home/pi/my-project/index.js:7
var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr:”192.168.1.14”, port:8080 } ) });
^

SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

The index.js file is :

var Blynk = require('blynk-library');
var Gpio = require('onoff').Gpio;
var led = new Gpio(23, 'out');

var AUTH = ‘code for local server’;

var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr:”192.168.1.14”, port:8080 } ) });

var v1 = new blynk.VirtualPin(1);

v1.on('write', function(param) {
	if (param[0] == '1'){
	  led.writeSync(1);
	} else {
  	  led.writeSync(0);
	}

	console.log('V1:', param[0]);
});

What am I doing wrong ? Almost giving up on blynk….

Can you clarify exactly what this means?

Would you like to provide a link to these instructions?

Pete.


This is Anna, if you don’t know her…
I don’t know how better explain global and loca…global is the blynk server… local is the server on my Pi

Okay, so I think you’re saying that you’ve previously used the Blynk cloud server, and now you’ve set up a local server and are attempting to connect your NodeJS client to your new local server.

I’m not a NodeJS user myself, but your new connection command seems okay, expect maybe for a few missing spaces and the wrong type of quotation marks. Does changing to this help…

var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr: "192.168.1.14", port: 8080 } ) });

Pete.

Magical…It worked…Thank you so much…I cannot believe I spent a few hours chasing this and did not make it work because of two blank spaces…Thank you Pete. I will start playing with Blynk now…