Skip to main content

Collect your first OPC UA point

This example polls one OPC UA numeric point whose value may be changed. First confirm that its current value is ingested, then change the point value and check the new value and source timestamp. The example uses type Double and a millisecond-precision target database. After verification passes, add more points following the full guide.

Where to operate: taosExplorer → Data Ingestion. Run preparation and verification SQL in the target cluster's Data Browser or taos CLI.

Data is written from OPC UA Server to TDengine. taosX or the taosX-Agent selected for the task performs collection. The collection host needs a matching OPC connector plugin. The execution identity needs source browse and read permissions. Task management permissions and target table creation and write permissions are also required.

1. Prerequisites​

1.1 Confirm the collection host and test point​

Ask the OPC UA administrator for the endpoint address, security mode, security policy, authentication method, and a readable Double test point that allows value changes and provides a source timestamp. Record its complete NodeId, current value, and source timestamp. If value changes are not permitted for your identity, ask the administrator to assist with verification.

warning

Change only an authorized test point. Do not change production points or weaken production server security policies to complete the test.

The configuration below uses ns=2;s=Demo/Temperature. This is not a default OPC UA Server point. If using another point, update the namespace, node filter, and verification table name together.

Confirm that the plugin is installed on the actual collection host, and check connectivity to OPC UA Server there. Browser access to taosExplorer does not prove that plugins and network access work on the collection host. For security mode Sign or SignAndEncrypt, prepare the client certificate and private key in advance and have OPC UA Server trust the certificate.

1.2 Prepare the target database​

Have an authorized TDengine TSDB administrator create a dedicated test database, or use an existing dedicated test database. If a database with the same name exists but is not intended for this test, use a new name and update subsequent configuration:

CREATE DATABASE taosx_opc_demo PRECISION 'ms';

2. Minimal configuration and startup​

  1. On the Data Ingestion page, click +Add Data Source. Set the name to quickstart_opcua, select OPC UA as the type, and select taosx_opc_demo as the target database.
  2. If a proxy is needed, select an online taosX-Agent that can reach OPC UA Server. Enter the OPC UA service address as host:port/path: remove the opc.tcp:// protocol prefix from the endpoint supplied by the administrator, retaining the actual port and path. Configure security mode, security policy, and authentication as required by the source, then click Connectivity Check.
  3. For Point set, select Select data points. Select the test point's namespace and enter a node ID expression. For ns=2;s=Demo/Temperature, select namespace 2 and enter expression ^ns=2;s=Demo/Temperature$. Click View point list and confirm that it matches only this point, of type Double.
  4. Set the supertable name to quick_opc_{type}, table name to t_{ns}_{id#/_}, and value column name to val. Leave value transformation empty. Select original_ts (original source timestamp) as the timestamp column, and set the timestamp column name to ts.
  5. Explicitly select observe for Collection mode, with an interval of 5 seconds. Check other advanced options. Do not enable automatic point addition or alarms and events mode for this test.
  6. Submit and confirm that the task starts. Keep the test point readable and record the source value and timestamp before and after one collection cycle.

If the test point is not Double, adjust mapping and verification to its actual type. Do not apply this numeric example directly to a string point. Do not use broad filters that include all production points.

3. Configuration that must be explicit in this example​

Enter the service address from the perspective of the actual collection host. 127.0.0.1 or localhost refers to the taosX host or selected taosX-Agent host. If OPC UA Server is on another host, enter a server address reachable from the collection host.

observe reads current values at intervals; subscribe receives server reports of data changes. This section explicitly selects polling every 5 seconds. This is not the default collection interval.

{type} expands by value type: Double produces supertable quick_opc_double. The NodeId in this section produces child table t_2_Demo_Temperature. For a different point name or namespace, use the actual names shown in the preview and target table list.

original_ts uses the source timestamp as the target primary key. A fallback time is used if the source timestamp is missing; this cannot establish that the source value was just updated. For the rules, see Time semantics for regular point values. This section requires a test point with a source timestamp. Compare at the target database's millisecond precision; preserving sub-millisecond parts is not required.

For secure connections, point filtering, and mapping rules, see OPC UA. OPC UA alarms and events uses a different model, so this section's point-value verification does not apply.

4. Verification​

4.1 Check the first collection​

Wait at least one collection interval plus the batch send time, then run the following in the target cluster's Data Browser or taos CLI:

SELECT ts, CAST(ts AS BIGINT) AS ts_ms, val
FROM taosx_opc_demo.`t_2_Demo_Temperature`
ORDER BY ts DESC LIMIT 10;

The child table name contains uppercase letters. Keep the backticks and use the actual generated name. The query must return at least one record whose val matches the source reading and whose ts_ms matches the source timestamp converted to milliseconds. When comparing time strings, first align the source and query client's time zones.

4.2 Change the test point and check again​

Ask the OPC UA administrator to change the test point to a recognizable new value, such as 26.5. Confirm that the source reads normally and its timestamp has updated. Record the new value and timestamp, wait at least one collection interval plus the batch send time, then repeat the query above.

Verification passes only when both the new record's value and source timestamp match this change. If the new value appears but the time is unexpected, continue checking timestamp configuration and source readings.

note

With original_ts, repeated polling that returns the same source timestamp does not necessarily increase the target row count. Do not use “one new row every five seconds” as the success criterion.

If no records are found, start with No data on first ingestion. For full configuration and limitations, see OPC UA. For stopping and recovery, see Restarts, checkpoints, and store-and-forward. For other symptoms, see Troubleshooting by symptom.