gyp WARN EACCES user “root” does not have permission to access the dev dir “/root/.node-gyp/6.9.5” gyp WARN EACCES attempting to reinstall using temporary dev dir “/usr/lib/node_modules/onoff/node_modules/epoll/.node-gyp”
make: Entering directory ‘/usr/lib/node_modules/onoff/node_modules/epoll/build’
CXX(target) Release/obj.target/epoll/src/epoll.o
SOLINK_MODULE(target) Release/obj.target/epoll.node
COPY Release/epoll.node
make: Leaving directory ‘/usr/lib/node_modules/onoff/node_modules/epoll/build’
/usr/lib
└─┬ onoff@1.1.1
└─┬ epoll@0.1.20
├── bindings@1.2.1
└── nan@2.4.0
Then in the next step:
pi@RaspberryPi3Sensehat:~ $ sudo npm install -g onoff
gyp WARN EACCES user “root” does not have permission to access the dev dir “/root/.node-gyp/6.9.5”
gyp WARN EACCES attempting to reinstall using temporary dev dir “/usr/lib/node_modules/onoff/node_modules/epoll/.node-gyp”
make: Entering directory ‘/usr/lib/node_modules/onoff/node_modules/epoll/build’
CXX(target) Release/obj.target/epoll/src/epoll.o
SOLINK_MODULE(target) Release/obj.target/epoll.node
COPY Release/epoll.node
make: Leaving directory ‘/usr/lib/node_modules/onoff/node_modules/epoll/build’
/usr/lib
└─┬ onoff@1.1.1
└─┬ epoll@0.1.20
├── bindings@1.2.1
└── nan@2.4.0
No, it should work. And it works even on non-raspi boards like Beaglebone or Omega so I wouldn’t suspect Blynk or OnOff. It’s most probably Nodejs<>OnOff relationship.
I have no Raspi 3 to check with.
Guys,
after you install onoff, what happens after you run the simplest onoff script?
var onoff = require("onoff");
as you can imagine, if you get this part working (which is not strictly related to Blynk, rather to onoff-nodejs relationship), Blynk will also recognize onoff. Hope that helps.
Meanwhile, I will think if I can simplify things a bit.
The onoff has issues while installing. I can give it a try on your test, but I am bit confused on which context I should do it. The line of code seems to be C++, should I be compiling that? I tried to compile with gcc but did not work. I was planning to use python for my programming, so not sure how to test your suggestion…
Can you explain to non-linux programmers exactly what you mean by “running” this command?
I have typed it verbatim in the CLI and get an error: -bash: syntax error near unexpected token `('
I have created a script with it that line:
and ran it… but nothing happens:
I ask, because I have managed to also (along side with the wiringPI method) get the “official??” method of Blynk installed on my older RPi, using some alternative methods of installing NODE, as my ARMv6 hardware (RPI model B ver 2.0) is not compatible with Blynk’s subscribed install method.
Thus, with NODE v6.9.1, NPM v4.1.2 and ONOFF v1.1.1 all installed, I am able to run the test script with virtual pins, the value display and two sliders (1st on V1 and the 2nd on GP18 - where I have an LED wired up)… but any 2nd slider movement gets an error.
@Gunner try adding this extract to test direct pin access:
var Gpio = require('/usr/local/lib/node_modules/onoff').Gpio,
relay = new Gpio(21, 'out'); // Pi BCM # 21
var v2 = new blynk.VirtualPin(2); // virtual pin to control GPIO 21
v2.on('write', function() {
if(relay.readSync() == 0) { // toggle gpio 21 from high to low
relay.writeSync(1);
}
else {
relay.writeSync(0);
}
});
@Costas Umm… I guess you meen just add it to the blynk-test.js example?
var Blynk = require('blynk-library');
var AUTH = '9ae42d15xxxxxxxxxxda5832f1';
var blynk = new Blynk.Blynk(AUTH, options = {
connector : new Blynk.TcpClient()
});
var v1 = new blynk.VirtualPin(1);
var v9 = new blynk.VirtualPin(9);
v1.on('write', function(param) {
console.log('V1:', param[0]);
});
v9.on('read', function() {
v9.write(new Date().getSeconds());
});
var Gpio = require('/usr/local/lib/node_modules/onoff').Gpio,
relay = new Gpio(21, 'out'); // Pi BCM # 21
var v2 = new blynk.VirtualPin(2); // virtual pin to control GPIO 21
v2.on('write', function() {
if(relay.readSync() == 0) { // toggle gpio 21 from high to low
relay.writeSync(1);
}
else {
relay.writeSync(0);
}
});
@Gunner ran you script, now called gunner.js and it is fine on my Zero.
Version mismatch is the important part of your error message. I guess your alternative installation methods for the B v2.0 Pi are the problem.
I suspect that as well… As I understand it, NPM is installed with NODE, but I have ran all the updates and have the latest versions of both NPM and ONOFF… so not sure what else I can do.
I could always run sudo apt-get upgrade node… but I believe I did that before and it I think it messes everything up somehow… But I am running it now to confirm
OK, that did nothing… but running npm install -g onoff again did allow me to run the script without errors. And now I can move the GP18 slider, also without errors… but also without any reaction from the PWM LED… bahhh,
What was I to add to the app to make the GPIO21 toggle? Button or switch on V2?