Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
946 Views

node js server on galileo

I want to make an opc-ua server on galileo gen 2, with a yocto built version of linux.

 

I've made, with some help from git, a complete version of that kind of server for raspberry pi 3, but i have some problems with porting it to galileo. I'm using for the server dht11 and ds18b20 sensors, but i can't manage to make it work on galileo. I have also this error on trying to run the server on galileo: Proxy is not defined.

Here is my code:

var opcua = require("node-opcua");

var w1bus = require("node-w1bus");

var bus = w1bus.create();

var rpiDhtSensor = require("rpi-dht-sensor");

function read_sensor(sensor,callback) {

bus.getValueFrom(sensor)

.then(function(res){ callback(null,res.result); })

.catch(callback);

};

function start_server() {

var server = new opcua.OPCUAServer({

port: 1234

});

server.buildInfo.productName ="Rapsberry OPCUA Server"

function post_initialize() {

var addressSpace = server.engine.addressSpace;

var devices = addressSpace.addFolder("ObjectsFolder",{ browseName: "Devices"});

var temperatureSensor = "28-041460c2a3ff";

install_sensor(temperatureSensor);

};

var tempValue = -20.0;

var tempValue1 = -20.0;

var humValue = -20.0;

function install_sensor(sensor) {

var addressSpace = server.engine.addressSpace;

var sensorName = "ds18b20";

var sensorName1 = "dht11";

var devices = addressSpace.rootFolder.objects.devices;

var sensor = addressSpace.addObject({

organizedBy: devices,

browseName: sensorName

});

var dht = new rpiDhtSensor.DHT11(27);

setInterval(function() {

var temperatureSensor = "28-041460c2a3ff";

read_sensor(temperatureSensor,function(err,result) {

tempValue = result.value;

});

var readout = dht.read();

tempValue1 = readout.temperature.toFixed(2);

humValue = readout.humidity.toFixed(2);

},3000);

addressSpace.addVariable({

propertyOf: sensor,

browseName: "temperature1",

dataType: "Double",

value: {

get: function () {

return new opcua.Variant({dataType: opcua.DataType.Double, value: tempValue });

}

}

});

addressSpace.addVariable({

propertyOf: sensor,

browseName: "temperature2",

dataType: "Double",

value: {

get: function () {

return new opcua.Variant({dataType: opcua.DataType.Double, value: tempValue1 });

}

}

});

addressSpace.addVariable({

propertyOf: sensor,

browseName: "humidity",

dataType: "Double",

value: {

get: function() {

return new opcua.Variant({dataType: opcua.DataType.Double, value: humValue });

}

}

});

};

server.initialize(post_initialize);

server.start(function() {

console.log("\n\nTemperature - OPCUAServer");

var endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl;

console.log("Server endpoint url is ", endpointUrl );

console.log("\n");

});

}

start_server();

Some help for making it work on Galileo, please??

0 Kudos
5 Replies
Highlighted
Community Manager
8 Views

Hello Cristina,

 

 

Thank you for your interest in the Intel Galileo board.

 

Your request has been received and is currently being investigated.

 

We will get back to you as soon as possible.

 

 

Regards,

 

Octavian

 

0 Kudos
Highlighted
Honored Contributor I
8 Views

Hi Cristina21r,

What are the errors you have?

Fernando.

0 Kudos
Highlighted
Beginner
8 Views

To begin with, when i run the code I attached eaarlier:

ReferenceError: Proxy is not defined

at UAVariable.bindExtensionObject (/server/node_modules/node-opcua/node_modu les/node-opcua-address-space/src/ua_variable.js:1599:32)

at bindServerDiagnostics (/server/node_modules/node-opcua/node_modules/node- opcua-server/src/server_engine.js:625:42)

at /server/node_modules/node-opcua/node_modules/node-opcua-server/src/server _engine.js:831:9

at /server/node_modules/node-opcua/node_modules/node-opcua-address-space/src /loader/load_nodeset2.js:818:18

at /server/node_modules/node-opcua/node_modules/node-opcua-address-space/nod e_modules/async/dist/async.js:1126:9

at /server/node_modules/node-opcua/node_modules/node-opcua-address-space/nod e_modules/async/dist/async.js:473:16

at replenish (/server/node_modules/node-opcua/node_modules/node-opcua-addres s-space/node_modules/async/dist/async.js:993:25)

at iterateeCallback (/server/node_modules/node-opcua/node_modules/node-opcua -address-space/node_modules/async/dist/async.js:983:17)

at /server/node_modules/node-opcua/node_modules/node-opcua-address-space/nod e_modules/async/dist/async.js:958:16

at /server/node_modules/node-opcua/node_modules/node-opcua-address-space/nod e_modules/async/dist/async.js:1123:13

I have connected ds18b20 sensor: dq to digital pin 2 on galileo gen2, gnd to gnd and vcc to 5 V, but the dht 11 not yet connected to my board.

Altought I will pass the error I mentioned before, I don't really expect for this code to work, because I understood that rpi-dht-sensor is for pi, and that's my probleem..i don't know exactly how to change the code in order to make it work on galileo..

0 Kudos
Highlighted
Community Manager
8 Views

Hello Cristina,

 

 

Thank you for your interest in the Intel Galileo board.

The sensor does not work with the standard library on a Galileo. Basically it is because of the strict timing requirements of the one-wire interface that the sensor uses.

Since the Intel Galileo board runs an operating system, it can take more time to switch a pin from input to output than on a microcontroller.

The workaround is to add a diode to split the one pin into two pins. This way the Galileo don't have to switch one pin between being input and output.

You can find here a tutorial on how to do that: https://www.build-electronic-circuits.com/intel-galileo-projects-simple-weather-station/

 

 

Also, support for one wire ds18b20 sensor has been implemented:

 

https://github.com/intel-iot-devkit/upm/commit/e679d40d44bd5fb4c71f8567bfe9ceb7f45c75c7

 

https://github.com/intel-iot-devkit/mraa/pull/415

 

 

Hope this helps.

 

 

Regards,

 

Octavian
0 Kudos
Highlighted
Community Manager
8 Views

Hello Cristina,

 

 

Do you require any more assistance with this issue?

 

 

Regards,

 

Octavian
0 Kudos