--- title: "Collector OPC UA" slug: "opc-ua-collector" tags: ["OPC UA", "DCM", "Data Collection Module"] updated: 2024-12-17T08:55:09Z published: 2024-12-17T08:55:09Z canonical: "kb.secomea.com/opc-ua-collector" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.secomea.com/llms.txt > Use this file to discover all available pages before exploring further. # Collector OPC UA The purpose of this article is to be a reference for the OPC UA collector part of the full Data Collection Module documentation The OPC UA collector is used to collect samples (data points) from any OPC UA enabled equipment, either by using a single collector or multiple collectors if collecting from multiple different devices. ## Config main The Config main (array of objects, mandatory) contain the following fields: | Function | Type | Importance | Description | | --- | --- | --- | --- | | **ConfigName** | string | mandatory | Unique name for this configuration file. Follows the rules for names. | | **ConfigDescription** | string | optional | text describing this configuration. | | **CheckpointInterval** | integer == 0 or >= 60 | optional | The interval with which all data from the internal datasample cache is saved to disk. The more unstable power that the SiteManager has, the more often data should be saved. Saving it often, however, will also cost performance and wear on the storage medium. A value of 0 means that it never checkpoints, otherwise it is an interval in seconds between saves. If not specified the value `900` (15 * 60sec = 15 minutes) is used. | | **AlarmsSaved** | integer >= 4 | optional | The number of alarms saved in the Store and Forward database. If this values is not specified, it will default to `32`. | | **WaitForNTP** | boolean | optional | Synchronize DCM data collection with NTP time. If this parameter is `true`, all DCM collectors will not begin collecting data until NTP is enabled and configured and NTP has synchronized date/time. If not specified, the value is `true`. | Since the JSON format itself doesn't define a comment notation, DCM accepts the field name **comment** with any type of value in any section. Example of comment: ``` "Comment": "Example of a comment for use in any section." ``` ## OPC UA Collector main The Collectors (array of objects, mandatory) list of elements contains the following fields: | Function | Type | Importance | Description | | --- | --- | --- | --- | | **CollectorName** | string | mandatory | Unique name (within this confguration file) of a device to collect data from. (This is the name used in the agent configuration.) Follows the normal rules for names. | | **CollectorDescription** | string | optional | Description of this collector. (For your use, no system function) | | **CollectorIPAddr** | string | optional | Default IP address (or DNS name) for the device to be polled. The agent Target IP address will take precedence over this. | | **CollectorPortno** | integer > 0 and < 65535 | optional | Default port number for the device to be polled. The agent Target Port number will take precedence over this. If neither **CollectorPortno** nor agent Target Port Number is specified, the appropriate port will be used, depending on the **Protocol** parameter value. | | **Alias** | string | optional | This is the **CollectorName** of another collector, from which all the parameters (except **CollectorName** , **CollectorDescription** , **CollectorIPAddr** and **CollectorPortno** ) are copied. An alias cannot refer to another alias. | | **Protocol** | string-enum | mandatory | The protocol used to collect data. Possible values are: `OPC-UA/TCP`, `Modbus/TCP`, `Http/GET` and `Simulator`. | | **ConnectRetryMin** | integer > 0 | mandatory | The minimum number of seconds before trying to re-establish a connection to the device being sampled. An exponential backoff algorithm is used to retry connection establishment, starting after **ConnectRetryMin** and increasing to **ConnectRetryMax.** | | **ConnectRetryMax** | integer > 0 | mandatory | The maximum number of seconds before trying to re-establish a connection to the device being sampled. | | **OPCUAAccess** | Object | optional | Collection of parameters needed to access a given OPC-UA/TCP server. | | **SamplePoints** | Array of objects | mandatory | List of samples to be collected, possibly aggregated and Store and Forward database. | ## **OPCUAAccess** *Note*: The Security mode is an EXPERIMENTAL new feature and all security-related configuration is subject to change. *Important*: **OPCUAUsername** and **OPCUAPassword** are deprecated and will probably be removed in a future release. The **OPCUAAccess** object contains the following elements: | Function | Type | Importance | Description | | --- | --- | --- | --- | | **OPCUASecurityMode** | string-enum | optional | The security mode for the communication channel between DCM (OPC-UA client) and the OPC-UA server. Possible values are: `none`, `sign` and `signencrypt`. Unless specified otherwise, `none` is set as default. | | **OPCUASecurityPolicy** | string | maybe-optional | The security policy is mandatory, when the **OPCUASecurityMode** is `sign` or `signencrypt`. Possible values are: `none`, `Basic128Rsa15`, `Basic256`, `Basic256Sha256` and `Aes128_Sha256_RsaOaep`. If not specified, `none` will be used. | | **OPCUACertificate** | string | optional | The name of the certificate used for authentication during the collection of data if the **OPCUASecurityMode** is `sign` or `signencrypt`. If not specified, the name `opcua-cert-CollectorName` will be used. If such a certificate does not exist in the certificate store, it will be created. | | **OPCUAPrivateKey** | string | optional | The name of the private key to use for encryption during collecting of data if the **OPCUASecurityMode** is `sign` or `signencrypt`. If not specified, the name `opcua-pkey-CollectorName` will be used. If such a private key does not exist in the certificate store, it will be created. | | **OPCUAServerCertificates** | array of strings | optional | The name of the certificates imported from the OPC-UA server(s), that the collector retrieves data from. If no server is specified, any server will be accepted as being valid. If specified as an empty array, then all certificates of the OPC-UA Server certificate type will be used. | | **OPCUAUserTokenType** | string-enum | mandatory | The user authentication methods used when collecting data. Possible values are: `anonymous`, `username`, `certificate` and `issuedtoken`. | | **OPCUAUserTokenName** | string | maybe-optional | Mandatory if **OPCUAUserTokenType** is `username`, `certificate` or `issuedtoken`. The field refers to an entry in/name from the certificate store, which should contain the following: For `username` a file with 2 lines of text - the username and the password. For `certificate` an X.509 certificate. For `issuedtoken` a BASE64 encoded text file. | | **OPCUAUsername** | string | maybe-optional | The username to use for the OPC-UA session. To use **OPCUAUsername** it is a requirement that **OPCUASecurityPolicy** and **OPCUASecurityMode** is set to something other than `none`. Note that this parameter is deprecated and will probably be removed in a future release. Instead, we recommend using **OPCUAUserTokenName** as it is more flexible and secure. | | **OPCUAPassword** | string | maybe-optional | The password to use for the OPC-UA session. To use **OPCUAPassword** it is a requirement that **OPCUASecurityPolicy** and **OPCUASecurityMode** is set to something other than `none`. Note that this parameter is deprecated and will probably be removed in a future release. Instead, we recommend using **OPCUAUserTokenName** as it is more flexible and secure. | | **OPCUAPath** | string | optional | Additional path component to the URL used for connecting to the OPC-UA server. | | **OPCUABrowseRootIds** | array of **OPCUABrowseRootId** | optional | The OPC-UA node id to start browsing for relative browse paths from. | | **OPCUATimeStampPolicy** | string-enum | mandatory | The timestamp to mark collected data with. Possible values are: `source`, `server` and `dcm`. If the polled OPC-UA server does not support the requested timestamp, DCM will fall back from `Source->Server->DCM`. This field also serves as the default value for the optional field **OPCUATimeStampPolicy** in sample **OPCUAObject.** | | **OPCUATimeout** | integer > 0 | optional | Timeout (in millisecond) for OPC-UA query requests. If not present the value `5000` is used. | ## Samplepoint The **SamplePoints** objects contains the following elements: | Function | Type | Importance | Description | | --- | --- | --- | --- | | **SampleName** | string | mandatory | Name of this sampled value (sometimes called a tagname). Follows the normal rules for names. | | **SampleDescription** | string | optional | Is a text description of this sample value. | | **SampleUnit** | string | optional | Is a description of the unit measurement for this sample. | | **SampleGroup** | string | optional | Designates (in some datasrvs) that all samplepoints in that group should be handled (displayed) together. The DCM system itself places no meaning on this group affiliation. | | **SamplesSaved** | integer > 0 | optional | Is the number of values collected that is saved in the Store and Forward database even after the values have been sent to all dataservers. When `0` is specified, the value can be used in aggregators, but nothing is sent via dataservers to cloud system. If left unspecified, values are only saved in the Store and Forward database until they have been delivered to all dataservers. | | **OnlySaveOnChanged** | bool | optional | Specifies whether new sample values should be saved to the Store and Forward database only if the values have changed since last sample. Defaults `false`. | | **ChangeLimit** | Integer/Double | optional | Only used if **OnlySaveOnChanged** is `true`. This describes a limit for what "changed" means. If a new sample value is this amount less or more than the previous sample value, it is considered the "same" value. This is a simple hysteresis to filter out inaccurate (jitter) measurements. | | **SampleDataType** | string-enum | mandatory | The type of data collected. The possible values are: `bool` (1 bit), `sbyte` (8 bit signed), `byte` (8 bit unsigned), `int16` (16 bit signed), `uint16` (16 bit unsigned), `int32` (32 signed), `uint32` (32 bit unsigned), `int64` (64 bit signed), `uint64` (64 bit unsigned), `float` (32 bit), `double` (64 bit), `string` (variable text up to 24575 bytes. Includes terminating NUL), `data` (variable data up to 24575 bytes). This collector might not support all `SampleDataType`s. | | **SampleMaxVDataSize** | integer > 0 and <= 24575 | optional | Is the max size of variable data enforced for this sample. This is only relevant for **SampleDataType** `string` and `data`. Defaults to `1024`. | | **SampleLowerLimit** | integer/double | optional | The lower limit for the collected data. If the collected data value is less than **SampleLowerLimit** it is evaluated in accordance with **SampleLimitDiscard** and **SampleLimitAlarm.** | | **SampleUpperLimit** | integer/double | optional | The upper limit for the collected data. If the collected data value is more than **SampleUpperLimit** it is evaluated in accordance with **SampleLimitDiscard** and **SampleLimitAlarm.** | | **SampleLimitDiscard** | bool | maybe-optional | Specify whether a sample limit violation results in the sample value being discarded. Mandatory if either **SampleLowerLimit** or **SampleUpperLimit** is present. | | **SampleLimitAlarm** | bool | maybe-optional | Specify whether a sample limit violation generates an alarm. Mandatory if either **SampleLowerLimit** or **SampleUpperLimit** is present. | | **OPCUAObject** | Object | maybe-optional | Description of how to address a specific OPC-UA object, when values are collected from it. Mandatory if the protocol type is `OPC-UA/TCP`. | ## OPCUABrowseRootId The OPCUABrowseRootId object contains the following fields: | Function | Type | Importance | Description | | --- | --- | --- | --- | | **BrowseRootID** | integer >= 0 | mandatory | Is a unique ID for this entry. (Used by the **OPCUAObject** entries). | | **NodeIdNameSpaceIndex** | integer >= 0 and < 65535 | maybe-optional | This is the OPC-UA NodeID type. (ID type of the tag) The possible values are: `numeric`, `string`, `guid` or `bytestring`. | | **NodeIdType** | string-enum | mandatory | This is the OPC-UA NodeID type. The possible values are: `numeric`, `string`, `guid`, `bytestring` or `browsename`. | | **NodeIdNumeric** | integer >= 0 and < 4294967295 | maybe-optional | This is OPC-UA NodeID numeric value. Only mandatory if the value of **NodeIdType** is `numeric`. | | **NodeIdString** | string | maybe-optional | This is OPC-UA NodeID string value. Only mandatory if the value of **NodeIdType** is `string` or `browsename`. For `browsename` it is the node browsename to be searched for, starting from **OPCUABrowseRootId** and forwards in the tree. | | **NodeIdGuid** | string | maybe-optional | This is OPC-UA NodeID GUID value. Only mandatory if the value of **NodeIdType** is `guid`. The format is hex-digits with hyphens enclosed in curly brackets: `{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}` (38 characters). | | **NodeIdByteString** | string | maybe-optional | This is OPC-UA NodeID byte string value. Only mandatory if the value of **NodeIdType** is `bytestring`. The format is hex-digits. Must not be an empty string and must contain a even number of hex digits. | | **NodeIdBrowsePath** | array of strings | maybe-optional | This is OPC-UA NodeID browse path. Only mandatory if the value of **NodeIdType** is `browsename`. This browsepath is relative to the official OPC-UA root folder namespaceindex 0 (numeric: 84). Each string in the array follows the [OPC-10000-3](https://reference.opcfoundation.org/Core/Part3/v104/docs/) section C.2.3 syntax: `[<namespaceindex>:]<browsename>` where the `<namespaceindex>` can be omitted if `namespaceindex` is 0. | ## **OPCUAObject** The **OPCUAObject** object contains the following fields: | Function | Type | Importance | Description | | --- | --- | --- | --- | | **NodeIdNameSpaceIndex** | integer >= 0 and < 6553 | maybe-optional | This is the OPC-UA namespace index. When **NodeIdType** is `browsename`, this index is not used and is therefore optional. | | **NodeIdType** | string-enum | mandatory | This is the OPC-UA NodeID type. The possible values are: `numeric`, `string`, `guid`, `bytestring` or `browsename`. | | **NodeIdNumeric** | integer | maybe-optional | This is OPC-UA NodeID numeric value. Only mandatory if the value of **NodeIdType** is `numeric`. | | **NodeIdString** | string | maybe-optional | This is OPC-UA NodeID string value. Only mandatory if the value of **NodeIdType** is `string`. | | **NodeIdGuid** | string | maybe-optional | This is OPC-UA NodeID GUID value. Only mandatory if the value of **NodeIdType** is `guid`. The format is hex-digits with hyphens enclosed in curly brackets: `{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}` (38 characters). | | **BrowseRootREF** | integer >= 0 and integer >= 0 | maybe-optional | This is a reference to the **OPCUABrowseRootIds** element with the same value of it's field **OPCUABrowseRootId**. This field is only used, when the **NodeIdType** is `browsename`. | | **NodeIdBrowsePath** | array of strings | maybe-optional | This is OPC-UA NodeID browse path. Only mandatory if the value of **NodeIdType** is `browsename`. This browsepath is relative to the browseroot specified with the **BrowseRootREF** value. If the **BrowseRootREF** is left unspecified, it is an absolute browsepath starting from the Root node. Each string in the array follows the [OPC-10000-3](https://reference.opcfoundation.org/Core/Part3/v104/docs/) section C.2.3 syntax: `[<namespaceindex>:]<browsename>` where the `<namespaceindex>` can be omitted if `namespaceindex` is 0. | | **NodeIdByteString** | string | maybe-optional | This is OPC-UA NodeID byte string value. Only mandatory if the value of **NodeIdType** is `bytestring`. The format is hex-digits. Must not be an empty string and must contain an even number of hex digits. | | **OPCUASampleInterval** | integer >= 0 | mandatory | The number of seconds between each sample of this OPC-UA object. If the interval is 0, only event-driven polling is used. | | **OPCUATimeStampPolicy** | string-enum | optional | The timestamp to mark this sample data with. Possible values are: `source`, `server` or `dcm`. If this field is not present the **OPCUATimeStampPolicy** filed from the **OPCUAAccess** object - that this sample belongs to - will be used instead. | ## Example configuration Example of collector with **OPCUAAccess,** **Samplepoints** and **OPCUAObject** objects: ``` { "CollectorName": "OmronOPCUA", "CollectorDescription": "Example Omron NX1 with OPC-UA Server", "Protocol": "OPC-UA/TCP", "ConnectRetryMin": 2, "ConnectRetryMax": 240, "OPCUAAccess": { "OPCUASecurityPolicy": "none", "OPCUAUserTokenType": "anonynmous", "OPCUATimeStampPolicy": "dcm" }, "SamplePoints": [ { "SampleName": "Temp1", "SampleDescription": "B1 Potmeter", "SamplesSaved": 1000, "SampleDataType": "int16", "SampleLimitDiscard": true, "SampleUpperLimit": 8100, "SampleLowerLimit": 0, "SampleLimitAlarm": false, "OPCUAObject": { "NodeIdNameSpaceIndex": 4, "NodeIdType": "string", "NodeIdString": "Analog1", "OPCUASampleInterval": 4 } } ] } ``` Example of collector for OPC UA server on Siemens PLC ``` { "CollectorDescription": "Example with Siemens PLC w/OPC-UA Server", "CollectorName": "Test2OPCUA", "ConnectRetryMax": 240, "ConnectRetryMin": 10, "OPCUAAccess": { "OPCUASecurityPolicy": "none", "OPCUATimeStampPolicy": "dcm", "OPCUAUserTokenType": "anonynmous" }, "Protocol": "OPC-UA/TCP", "SamplePoints": [ { "OPCUAObject": { "NodeIdNameSpaceIndex": 3, "NodeIdString": "\"DB_MRUSim\".\"Out\"", "NodeIdType": "string", "OPCUASampleInterval": 1 }, "SampleDataType": "double", "SampleDescription": "AHC curve", "SampleName": "AHC", "SamplesSaved": 10 } ] } ```