Code Monkey home page Code Monkey logo

mqtt2opcua's Introduction

Bi Directional MQTT to OPCUA Bridge

Expose MQTT topics to an OPCUA server via folders. Supports read/write.

Usage:

node creates an OPC server that:

  1. Connects to an MQTT broker
  2. Subscribes to '#' or a predefined set of topics
  3. On 1st Message of an unseen topic it creates the folder paths and node (last part of path) with nodeId s=topic
  4. On all onMessage calls, it keeps track of the topic's payload
  5. On Set requests it publishes the raw value from the OPCUA client
  6. On Get requests it returns the formatted persistant payload

Note:

Recently upgraded to support MQTT auth and to remove spaces from OPCUA name in example

PLEASE REMEMBER TO CHECK FOR UPDATES REGULARLY!

Todo: Add authentication

For configuration options and formatting of payloads, see handlers example below.

var  mqtt2opc = require("../mqtt2opcua").run;
var  Events = require('events').EventEmitter;

forward = new Events();
backward = new Events();

// Set up forward and reverse data conversion functions
// These are based on topic path - the finer grained pattern will be used.
// Examples below

forward.on("$SYS/broker/bytes/#", function(payload) {
    return {
            dataType: "Int32",
            value: parseInt(payload)
         }
});

backward.on("$SYS/broker/bytes/#", function(variant) {
            return {
                topic:variant.topic,
                payload:variant.value
            };
});

options = {
    opcHost:"localhost",
    opcPort:"4334",
    mqttHost:"localhost",
    mqttPort:"1883",
    debug:true,
    roundtrip:false,    // Set to true if you wish to enforce the integrity of round trip communications	
    forward:forward,	// data converter - mqtt -> opcua
    backward:backward,	// data converter - opcua -> mqtt
    //topics:['#','$SYS/#'] // Customize to override. These are the default so uncessary.
};

var server = new mqtt2opc(options);

Please feel free to fork and improve.

Andrew McClure, Director AgSense - Bringing I.o.T to NZ Agriculture

Koha (Donation) - If you like our work and would like to make a small donation to help us continue

mqtt2opcua's People

Contributors

accyroy avatar hoblins avatar

Watchers

Thomas Lecarpentier avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.