Cannot connect with opc-ua on raspberry

2 ビュー (過去 30 日間)
Ruica Cristina
Ruica Cristina 2018 年 6 月 7 日
編集済み: Walter Roberson 2018 年 6 月 18 日
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();
This is my server on raspberry. I have w10..and i want just to get the values from those sensors..temperature and humdity.. but when I try to connect, i get this
>> uaClient = opcua('opc.tcp://192.168.1.107:1234');
Error using opc.ua.Client (line 302)
Server URL must start with 'opc.tcp://hostname:port'.
Error in opcua (line 32)
uaObj = opc.ua.Client(varargin{:});
  1 件のコメント
Ruica Cristina
Ruica Cristina 2018 年 6 月 18 日
Any help???

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeUnified Architecture についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by