• Home
  • Raspberry Pi
  • Codesys eCockpit
  • Python
  • Docker
  • Embedded Programming
Brighter Side Tech
  • Home
  • Raspberry Pi
  • Codesys eCockpit
  • Python
  • Docker
  • Embedded Programming
No Result
View All Result
  • Home
  • Raspberry Pi
  • Codesys eCockpit
  • Python
  • Docker
  • Embedded Programming
No Result
View All Result
Brighter Side Tech
No Result
View All Result
Home Python

OPC UA Client In Python

Mwesigwa Peter by Mwesigwa Peter
February 1, 2023
in Automation, Python
0
OPC UA Client In Python

OPC UA Client In Python

0
SHARES
944
VIEWS
Share on FacebookShare on Twitter

The Open Platform Communications (OPC) is a common and popular communication standard for reliable and secure exchange data in the industrial and automation domains. This standard, among other applications, specifies a series of specifications for exchange of data between servers and clients as well as server to server communication.

OPC UA (Unified Architecture) is a service oriented architecture platform developed to enhance, improve and surpass the abilities and functionalities of the Classic OPC standard, sometimes referred to as OPC Classic.

With its Open Connectiveness, proven security and reliability, OPC UA has become a favored and recognized protocol in the industrial and automation domains. The protocol can work and easily integrate with very many software platforms. In this Tutorial, we are gong to see how to develop a python based OPC UA client to communicate with an OPC UA server.

Step 1. Set up your OPC UA Server

The first step is to make your server ready, up and running. In Case you don’t have a real server, you may use a simulation server for the purpose of testing your client. Follow the tutorial below to see how to install and configure a Simulation OPC UA Server.

Step 2: Install the required python libraries

The opcua python library contains a set of packages and modules to facilitate the implementation of both OPC UA severs and clients in python. To install the library:

pip3 install opcua

Step 3: The code

Import the client module and specify your server endpoint

from opcua import Client
url = "opc.tcp://DESKTOP-FL73J86.mshome.net:53530/OPCUA/SimulationServer"

Create a client object by passing your server endpoint

client = Client(url)

Connect to your server

client.connect()

If your connection was successful, you can now get nodes from our server using the get_node() function and extract data from those nodes using the get_values() function. To get the node, you need to specify the Node namespace along with the node id

tempNode = client.get_node("ns=3;i=1001")
temperature = tempNode.get_value()

To set a value for a node on the server, first you need to get the node, by specifying its namespace and node id. Then you can use the set_values() function to set its value.

numNode = client.get_node("ns=3;i=1008")
client.set_values([numNode], [num+1])

Full Code

You can get the full code from github: brightersidetech/opcua_client_python

Tags: industrial automationopcuapython
Previous Post

Raspberry Pi Ic2 Protocol with Sequent Microsystems Stackable Cards in Python

Next Post

OPC UA Sever in Python

Mwesigwa Peter

Mwesigwa Peter

Related Posts

Parsing JSON Data in Codesys
Automation

Parsing JSON Data in Codesys

Parsing JSON Data in Codesys is quite an important operation especially when exchanging data over the REST API. The data...

by Mwesigwa Peter
January 25, 2025
Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime
Automation

Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

Introduction Codesys Runtime for Linux ARM SL allows you to program your Raspberry Pi according t the IEC 61131-6 standard...

by Mwesigwa Peter
October 7, 2024
Next Post
OPC UA Sever in Python

OPC UA Sever in Python

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Parsing JSON Data in Codesys
Automation

Parsing JSON Data in Codesys

by Mwesigwa Peter
January 25, 2025
0

Parsing JSON Data in Codesys is quite an important operation especially when exchanging data over the REST API. The data...

Read moreDetails
Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

October 7, 2024
ARM error: no member named ‘IP’ in ‘NVIC_Type’ Solved

ARM error: no member named ‘IP’ in ‘NVIC_Type’ Solved

July 18, 2024
TCP Socket Client Implementation in Codesys

TCP Socket Client Implementation in Codesys

January 11, 2024
Modbus TCP Master Simulator

Modbus TCP Master Simulator Tool – Free Download

October 14, 2023
Parsing JSON Data in Codesys

Parsing JSON Data in Codesys

by Mwesigwa Peter
January 25, 2025
0

Parsing JSON Data in Codesys is quite an important operation especially when exchanging data over the REST API. The data...

Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

by Mwesigwa Peter
October 7, 2024
0

Introduction Codesys Runtime for Linux ARM SL allows you to program your Raspberry Pi according t the IEC 61131-6 standard...

ARM error: no member named ‘IP’ in ‘NVIC_Type’ Solved

ARM error: no member named ‘IP’ in ‘NVIC_Type’ Solved

by Mwesigwa Peter
July 18, 2024
0

This is how to solve the error: no member named 'IP' in 'NVIC_Type' Open the misc.c file : AppData\Local\Arm\Packs\Keil\STM32F1xx_DFP\2.4.1\Device\StdPeriph_Driver\src\misc.c, if you are...

TCP Socket Client Implementation in Codesys

TCP Socket Client Implementation in Codesys

by Mwesigwa Peter
January 11, 2024
0

This is a TCP socket client implementation in codesys to run on your PLC and connect to any TCP Socket...

About Brighterside Tech

Brighter Side Tech

As a hobbyist Engineer and Programmer , i love to share my learnings and solutions to technical challenges that i face during work and studying. My website gives me the ability to express my ideas and such solutions to the wider audience

Contact: admin@brightersidetech.com

Browse by Category

  • Automation
  • Codesys eCockpit
  • Docker
  • Embedded Programming
  • Python
  • Raspberry Pi
https://youtu.be/Lkrma5f60rs

Recent News

Parsing JSON Data in Codesys

Parsing JSON Data in Codesys

January 25, 2025
Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

Configure Raspberry Pi Serial ports as COM ports for Codesys Runtime

October 7, 2024
ARM error: no member named ‘IP’ in ‘NVIC_Type’ Solved

ARM error: no member named ‘IP’ in ‘NVIC_Type’ Solved

July 18, 2024
  • Home
  • Raspberry Pi
  • Codesys eCockpit
  • Python
  • Docker
  • Embedded Programming

© 2024 Brighterside Tech.

No Result
View All Result
  • Home
  • Raspberry Pi
  • Codesys eCockpit
  • Python
  • Docker
  • Embedded Programming

© 2024 Brighterside Tech.