Get in touch:

+64 (0) 22 186 36 50

7 days a week
from 8:00 am to 8:00 pm


MQTT to OPCUA Protocol Gateway released as open source

Sat, 08/01/2015 - 09:00 -- andrew

Surprisingly a tool to convert between the emerging MQTT protocol and the industrial OPCUA standard did not exist so we have rolled our own.  

Please feel free to view here or install via npm.


Bi Directional MQTT to OPCUA Bridge

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


- npm install mqtt2opcua

- cd mqtt2opcua - npm link (view/edit examples/run.js)

- node examples/run.js 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



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 {

options = {
    forward:forward,	// data converter - mqtt -> opcua
    backward:backward,	// data converter - opcua -> mqtt
    //topics:['#','$SYS/broker/#'] // Customize to override. These are the default so uncessary.

var server = new mqtt2opc(options);