FactoryIQ OpcUA icon

FactoryIQ OpcUA

Read and write data to OPC UA servers

Actions2

Overview

This node enables reading and writing data to OPC UA (Open Platform Communications Unified Architecture) servers, which are widely used in industrial automation for secure and reliable machine-to-machine communication. The "Read" operation allows users to fetch values from one or more OPC UA nodes by specifying their node IDs. This is useful for monitoring sensor data, machine states, or other real-time information exposed by an OPC UA server.

Typical use cases include:

  • Reading temperature, pressure, or other sensor values from industrial equipment.
  • Monitoring status variables or alarms in a manufacturing process.
  • Integrating OPC UA data into workflows for logging, alerting, or further processing.

For example, a user can specify multiple node IDs representing different sensors and retrieve their current values in a single execution of the node.

Properties

Name Meaning
Node IDs One or more OPC UA node IDs to read values from. Each node ID should be entered separately (e.g., ns=1;s=Temperature).

Output

The output JSON contains a single object with the following structure:

  • timestamp: The Unix timestamp when the read operation was performed.
  • source: Identifier of the source connection (either a connection pool label or a unique string).
  • protocol: Always "opcua" indicating the protocol used.
  • address: Either the single node ID if one node was read, or a summary string like "N nodes" if multiple nodes were read.
  • metrics: An object mapping each requested node ID to its read value. If a node could not be read successfully, its value will be null.
  • status: Overall status of the read operation. "Good" if all nodes were read successfully, otherwise "Partial" or the specific error code if only one node was requested.
  • meta: Metadata about the read operation:
    • For a single node: includes the data type of the value and any error code if applicable.
    • For multiple nodes: includes a map of data types per node, any errors per node, total node count, and the list of node IDs.

Example output JSON for reading two nodes might look like:

{
  "timestamp": 1687000000000,
  "source": "n8n-opcua-pool",
  "protocol": "opcua",
  "address": "2 nodes",
  "metrics": {
    "ns=1;s=Temperature": 22.5,
    "ns=1;s=Pressure": 101.3
  },
  "status": "Good",
  "meta": {
    "dataTypes": {
      "ns=1;s=Temperature": "Double",
      "ns=1;s=Pressure": "Double"
    },
    "nodeCount": 2,
    "nodeIds": [
      "ns=1;s=Temperature",
      "ns=1;s=Pressure"
    ]
  }
}

Dependencies

  • Requires an OPC UA server endpoint accessible via network.
  • Requires valid OPC UA credentials configured in n8n, including support for anonymous, username/password, or X509 certificate authentication.
  • Uses an internal connection pool to manage OPC UA client connections efficiently.
  • Depends on the OPC UA client library bundled as a vendor dependency.
  • No additional environment variables are required beyond the configured credentials.

Troubleshooting

  • No Node IDs Provided: The node throws an error if no node IDs are specified for reading. Ensure at least one valid node ID is entered.
  • Invalid Credentials: Errors occur if OPC UA credentials are missing or incomplete, especially for X509 authentication which requires both certificate and private key.
  • Connection Failures: Network issues, incorrect endpoint URLs, or server unavailability cause connection errors. Verify the endpoint URL starts with opc.tcp:// or opc.https:// and that the server is reachable.
  • Read Failures: Individual node read failures return partial results with error codes per node. Check node IDs for correctness and server permissions.
  • Timeouts or Session Issues: The node uses session timeouts and retries internally; persistent failures may require checking server load or configuration.

Common error messages:

  • "At least one Node ID must be provided for reading." — Add valid node IDs.
  • "No OPC UA credentials provided." — Configure credentials in n8n.
  • "X509 authentication requires both certificate and private key." — Provide both certificate and private key for this auth type.
  • "Failed to connect or authenticate to OPC UA server." — Check network, endpoint URL, and credentials.
  • "Failed to read node values." — Verify node IDs and server access rights.

Links and References

Discussion