RPi 3 Blynk will not connect

Very new to Raspberry Pi and Blynk. I have followed the instructions and have the correct modules loaded but,

When running blynk.js error returned :

pi@pool:~ $ blynk.js -token-
OnOff mode
fs.js:50
throw new
TypeError(’“options” must be a string or an object, got ’ +
^
TypeError: “options” must be a string or an object, got number
instead.
at getOptions (fs.js:50:11)
at fs.readFileSync
(fs.js:465:13)
at Array.map (native)
at exports.SslClient.connect
(/usr/lib/node_modules/blynk-library/blynk-node.js:169:42)
at doConnect
(/usr/lib/node_modules/blynk-library/blynk.js:544:15)
at Blynk.connect
(/usr/lib/node_modules/blynk-library/blynk.js:557:5)
at new Blynk
(/usr/lib/node_modules/blynk-library/blynk.js:385:10)
at Object.
(/usr/lib/node_modules/blynk-library/bin/blynk-client.js:10:13)
at Module._compile
(module.js:573:32)
at Object.Module._extensions…js
(module.js:582:10)

I can not find any reference to this error. Could someone please help?

I can’t help, but I have exactly the same issue. I had the thing working, sort of, until I upgraded Node.js to 7.2.0

Ah, OK, I downgraded Node.js and it is working!

What is you nodejs version?

$ node --version
v6.9.1

Now v6.9.1 (I’d gone back to an even earlier version but after seeing your question went to 6.9.1). Which works fine.

As a completely unrelated aside, it is SO much easier to work Blynk with Arduino. As a non techie, I’m really struggling with the Pi. But Blynk is still the bomb. Thanks!

i have the same problem, im trying to setup following http://www.instructables.com/id/Raspberry-Pi-Nodejs-Blynk-App-DHT11DHT22AM2302/, but the js

var blynkLib = require('blynk-library');
var sensorLib = require('node-dht-sensor');

var AUTH = '74b23f650d264189bddaa80be6262c8a';

// Setup Blynk
var blynk = new blynkLib.Blynk(AUTH);

// Setup sensor, exit if failed
var sensorType = 22; // 11 for DHT11, 22 for DHT22 and AM2302
var sensorPin  = 4;  // The GPIO pin number for sensor signal
if (!sensorLib.initialize(sensorType, sensorPin)) {
    console.warn('Failed to initialize sensor');
    process.exit(1);
}

// Automatically update sensor value every 2 seconds
setInterval(function() {
    var readout = sensorLib.read();
    blynk.virtualWrite(3, readout.temperature.toFixed(1));
    blynk.virtualWrite(4, readout.humidity.toFixed(1));

    console.log('Temperature:', readout.temperature.toFixed(1) + 'C');
    console.log('Humidity:   ', readout.humidity.toFixed(1)    + '%');
}, 2000);


give me the same error . im using RASPBIAN JESSIE WITH PIXEL, raspberry pi 3, node 7.2.0 ( im downgrade to 7.1.0, 7.0.0) the error is :

OnOff mode
fs.js:50
    throw new TypeError('"options" must be a string or an object, got ' +
    ^

TypeError: "options" must be a string or an object, got number instead.
    at getOptions (fs.js:50:11)
    at fs.readFileSync (fs.js:465:13)
    at Array.map (native)
    at exports.SslClient.connect (/usr/lib/node_modules/blynk-library/blynk-node.js:169:42)
    at doConnect (/usr/lib/node_modules/blynk-library/blynk.js:544:15)
    at Blynk.connect (/usr/lib/node_modules/blynk-library/blynk.js:557:5)
    at new Blynk (/usr/lib/node_modules/blynk-library/blynk.js:385:10)
    at Object.<anonymous> (/home/pi/test.js:7:13)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)

for node <6.9.1 the error is :
pi@raspi:~ $ node test.js 
module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: Module version mismatch. Expected 48, got 51.
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/pi/test.js:2:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

please any help

Thanks for reporting, I will re-check it soon.

1 Like

DietPi #140 - the same errors:

root@DietPi:~# node -v
v7.3.0

root@DietPi:~# blynk.js xxxxxxxxxxxxxxxxxxxxxxxx
OnOff mode
fs.js:50
throw new TypeError(’“options” must be a string or an object, got ’ +
^

TypeError: “options” must be a string or an object, got number instead.
at getOptions (fs.js:50:11)
at fs.readFileSync (fs.js:465:13)
at Array.map (native)
at exports.SslClient.connect (/usr/local/lib/node_modules/blynk-library/blynk-node.js:169:42)
at doConnect (/usr/local/lib/node_modules/blynk-library/blynk.js:546:15)
at Blynk.connect (/usr/local/lib/node_modules/blynk-library/blynk.js:559:5)
at new Blynk (/usr/local/lib/node_modules/blynk-library/blynk.js:385:10)
at Object. (/usr/local/lib/node_modules/blynk-library/bin/blynk-client.js:10:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)

On LinuxMint all works fine :slight_smile:

/node_modules/blynk-library/blynk-node.js
find 169 line
if (self.ca) { opts.ca = self.ca.map(fs.readFileSync); }
and replace it with:
if (self.ca) {
opts.ca = [fs.readFileSync(self.ca[0])];
}

or
if (self.ca) {
opts.ca = self.ca.map(function(item){
fs.readFileSync(item)
});
}

this should works too

1 Like

Thx, will get to it soon.

1 Like

Should be fixed now.