Skip to main content

Monitoring a Single Variable

This tutorial shows you how to monitor a single OPC UA variable and receive notifications whenever its value changes.

The Monitor Node subscribes to data changes on the OPC UA server. Unlike the Read Node which retrieves values on demand, the Monitor Node continuously listens for changes and sends notifications automatically.

Prerequisites

  • An active connection to an OPC UA server (see Create a connection)
  • A subscription configured in the connection endpoint
  • The NodeId of the variable you want to monitor

Configuration

Name

Specify a descriptive name for the node to identify it in your flow.

Endpoint

Select the predefined endpoint of the OPC UA server. The endpoint must have at least one subscription configured.

Subscription

Choose the subscription to use for monitoring. The subscription defines:

  • Publishing Interval: How often the server sends batches of notifications
  • Lifetime: How long the subscription remains active without activity
  • Max Notifications: Maximum number of notifications per publish cycle

A single subscription can handle multiple monitored items efficiently.

Start Immediately

When checked, the node begins monitoring as soon as the flow starts, using the NodeId specified in the configuration.

tip

Leave this checked for simple scenarios where you monitor a fixed variable.

NodeId

Specify the NodeId or browse path of the variable to monitor. Supported formats:

Direct NodeId:

ns=1;s=Temperature

Browse Path:

/2:MyDevice/1:MyTemperatureSensor/2:ParameterSet/3:Temperature

Verified Browse Path:

[/2:MyDevice/1:MyTemperatureSensor/2:ParameterSet/3:Temperature](ns=1;s=Temperature)

Use the flask button to verify your NodeId or the ... button to browse the server's address space.

Sample Interval

The interval (in milliseconds) at which the OPC UA server samples the variable for changes. Default: 1000 ms

The server samples the value at this rate and compares it to the previous value. Notifications are only sent when an actual change is detected.

note

According to OPC UA Specification Part 4, the server only sends notifications when the data value actually changes.

Example values:

  • 1000 - Sample every second
  • 500 - Sample twice per second
  • 100 - Sample 10 times per second
  • 0 - Use the server's minimum sampling interval

Queue Size

The maximum number of notifications to store in the queue. Default: 1000

If the client cannot process notifications fast enough, they accumulate in this queue. When full, the behavior depends on the "Discard Oldest" setting.

Discard Oldest

When the queue is full:

  • Checked (default): Oldest notifications are removed to make room for new ones
  • Unchecked: Newest notifications are discarded
tip

Keep the default (checked) to ensure you always receive the most recent values.

Example Flow

Here's a basic example to monitor a temperature sensor:

[
{
"id": "monitor1",
"type": "OpcUa-Monitor",
"name": "Monitor Temperature",
"endpoint": "opcua_endpoint1",
"subscription": "subscription1",
"startImmediately": true,
"nodeId": "ns=1;s=Temperature",
"samplingInterval": 1000,
"queueSize": 10,
"discardOldest": true
},
{
"id": "debug1",
"type": "debug",
"name": "Show Temperature"
}
]

Flow Setup:

  1. Add Monitor Node: Drag the OpcUa-Monitor node to your flow
  2. Configure Endpoint: Select your OPC UA server endpoint
  3. Select Subscription: Choose an existing subscription
  4. Set NodeId: Enter ns=1;s=Temperature (adjust to your server)
  5. Configure Sampling: Set sample interval to 1000 ms
  6. Enable Start Immediately: Check the box
  7. Deploy: Deploy your flow

Expected Output

The Monitor node sends a message each time the temperature changes:

{
"topic": "ns=1;s=Temperature",
"payload": 23.5,
"statusCode": {
"value": 0,
"description": "Good"
},
"sourceTimestamp": "2024-11-24T10:30:45.123Z",
"serverTimestamp": "2024-11-24T10:30:45.125Z"
}

Message Properties:

  • payload: The current value (23.5°C in this example)
  • statusCode: Quality of the data (Good, Bad, Uncertain)
  • sourceTimestamp: When the device measured the value
  • serverTimestamp: When the server received the value

Output Formats

You can control the output format using msg.outputType:

Value Format (Default)

Only the value is returned in the payload:

{
"payload": 23.5
}

DataValue Format

Complete OPC UA DataValue with all metadata:

{
"payload": {
"value": 23.5,
"statusCode": {
"value": 0,
"description": "Good"
},
"sourceTimestamp": "2024-11-24T10:30:45.123Z",
"serverTimestamp": "2024-11-24T10:30:45.125Z",
"sourcePicoseconds": 0,
"serverPicoseconds": 0
}
}

Tips & Best Practices

Initial Value Notification

You'll always receive an initial notification when monitoring starts, even if the value hasn't changed. This confirms the subscription is active.

Efficient Sampling

  • Set samplingInterval to match your application's needs
  • Don't sample faster than necessary (wastes server resources)
  • Use 0 to let the server choose the optimal interval

Queue Management

  • For critical data: Use large queue size with "Discard Oldest" enabled
  • For real-time data: Use small queue size to avoid stale values
  • Monitor msg.sequenceNumber to detect missed notifications

Connection Management

The Monitor node automatically:

  • Reconnects if the connection is lost
  • Re-establishes subscriptions
  • Resumes monitoring without manual intervention

Troubleshooting

No Notifications Received

  1. Check Connection: Verify the endpoint is connected (green dot)
  2. Verify NodeId: Use the flask button to validate the NodeId
  3. Check Subscription: Ensure the subscription is active
  4. Review Status: Look for error messages in the debug panel

Too Many Notifications

  • Increase the samplingInterval to reduce sampling frequency
  • Implement deadband filtering (see Deadband Filtering)
  • Use queue size to buffer bursts

Missing Notifications

  • Increase queueSize to buffer more notifications
  • Check if "Discard Oldest" is appropriately set
  • Verify network stability

Next Steps

See Also