Main Content

Configure OPC UA Client in Simulink

Configure an OPC Unified Architecture (UA) client to read or write data in Simulink® using the OPC UA Read or OPC UA Write blocks.

In the Simulink toolstrip, click Model Settings in the Modeling tab to open the Configuration Parameters dialog box. In the dialog box, click the OPC Configuration pane to configure the required OPC UA clients.

Simulink toolstrip

Alternately, click Configure servers in the OPC UA Read or OPC UA Write blocks to open the OPC Configuration pane.

Block mask - Configure servers

The OPC Configuration pane lists all the OPC UA clients that you configure in the current model. You can use the buttons in this window to add, delete, connect, disconnect, and configure the clients.

  • Add: Create a new OPC UA client. Simulink configures the client by default with the best available security policy.

  • Delete: Delete the selected client.

  • Connect: Enable server connection for the selected client.

  • Disconnect: Disconnect the selected client.

  • Configure: Edit the security policy of the selected client.

OPC Configuration pane

OPC UA Client Configuration

Complete these steps to configure an OPC UA client for a Simulink model.


The OPC Configuration pane is automatically enabled in the Configuration Parameters dialog box of the model on including either an OPC UA Read or OPC UA Write block in the model.

Step 1: Create OPC UA Client

  1. To create a new OPC UA client, click Add. The Add OPC UA Client dialog box lists localhost as the default Hostname. You can add any valid OPC UA discovery URL in this field.

    Add OPC UA Client


    Before scanning the localhost for installed OPC UA servers, you must set up a Local Discovery Service (LDS) on the host computer, as described in Install a Local Discovery Service for OPC UA Server Discovery.

  2. To view the available servers, click Scan OPC UA Servers. Select a server.

    Scan OPC UA Servers

  3. Simulink creates a new OPC UA client for the selected OPC UA server with the best available security policy and adds the client to the OPC UA clients table.

    OPC UA Client table

Step 2 (Optional): Configure Security Policy of OPC UA Client

By default, Simulink configures every client with the best available security policy. To edit the security policy, disconnect the client and click Configure. From the list, select a channel security policy and its corresponding message security mode. For more information on security policies, see OPC UA Security.


Security Considerations: To enable a secure communication with an OPC UA server, use a strong channel security policy and message security mode.

You can expose your system to security risks when you select the None option in the MessageSecurityMode and ChannelSecurityPolicy settings. Use this setting only in a trusted environment.

If you need to connect to an OPC UA server that does not support a security policy, request the server administrator to enable a strong channel security policy and message security mode for the server. These settings enable encryption and authentication and safeguard your data and operations.

Configure OPC UA Client

Step 3: Connect OPC UA Client

  1. Select a client from the OPC UA clients table and click Connect. The Connect OPC UA Client dialog box displays the three types of user identity tokens supported by the OPC UA servers. For more information on user authentication, see OPC UA Security.

    Select User Identity Token

  2. Select the appropriate user identity token and fill in the details. Click Connect.

    • Anonymous token requires no input from user.

    • Username token requires a valid Username and Password.

    • Certificate token requires a Certificate File (*.DER file), a Private Key File (*.PEM file) and a Private Key Password.

  3. Once the client is successfully connected, its status in the OPC UA clients table updates to Connected.

    OPC UA Client Connected

Step 4: Update Client Information in Model

Click OK in the Configuration Parameters window to update the model with information about the new OPC UA client. The changes you make to the OPC UA clients table using the Connect, Disconnect, and Configure are instantaneous.

Step 5: Configure OPC UA Block with Server Connection

  1. The OPC UA blocks in the model list all the server connections that you have added in the OPC UA clients table.

    OPC UA Block Masks

  2. Select the Server to associate the block with the corresponding OPC UA client.