I got a simple node.js code running on my banana pi m1
it reads two ds18b20 to vpins, but it uses timer interval…
So im also want to controll relay board with virtual pin in this code, but getting trouble with it
If i left only 2 ds18b20 code in my .js it works
esle if
i wrote only vpin relay controll(extenal script)
it works too
esle more if
if i get whose codes together - my .js did not react on my button wiget, but gets temperature to vpins!!!
here are full codes .js i think anyone can crop it and imagine 2 others
var temp1;
var temp2;
var temp3;
const spawn = require("child_process").spawn;
var AUTH = "mydulltoken";
var blynk = new Blynk.Blynk(AUTH, options = {
connector : new Blynk.TcpClient( options = { addr:"localadres", port:8442 } )
});
var v1 = new blynk.VirtualPin(1);
var V2 = new blynk.VirtualPin(2);
v1.on("write", function(param) {
console.log("im here");
if (param =="0") {
console.log("V1:", param);
const sh = spawn("/bin/sh", ["/home/user/blynkscript/somescript1on.sh"]);
} else {
console.log("V1:", param);
const sh = spawn("/bin/sh", ["/home/user/blynkscript/somescript1off.sh"]);
}
});
W1Temp.getSensor("28-8000000112e2").then(function (sensor2) {
setInterval(function() {
var temp2 = sensor2.getTemperature();
if (temp2 == false) {
temp2 = temp3;
console.log("!!!!!!!! alse happening!!!!!!!!!!");
console.log("Previous temp is:", temp2, "°C");
} else {
console.log("Actual temp2:", temp2, "°C");
};
temp3 = temp2;
blynk.virtualWrite(21, temp2);
}, 500);
});
blynk.on("connect", function() { console.log("Blynk ready."); });
blynk.on("disconnect", function() { console.log("DISCONNECT"); });
Im think that im mistaking in cycle creation.
Thanx for possible help… Im a bit newbee in node.js
Gunner and Costas - thx for formating my subject