Products and Services
OPC UA - ESP8266 (Arduino)
Topic: OPC UA - ESP8266 (Arduino)
(Read 302 times)
OPC UA - ESP8266 (Arduino)
Nov 22, 2019, 08:48 pm
OPC UA (Unified Architecture) has existed since 2008. It is mainly used as a software communication tool - protocol for M2M (Machine-to-mechine) communication. It is used to exchange system states, values from sensors, etc. It works on the principle of a client and an OPC UA server that receives information but can also distribute it.
There is a pattern known for example from the MQTT protocol in the form of Publish, Subscribe. OPC UA is distributed under the free GPL 2.0 license, fully supporting cross-platform. OPC UA is a serial protocol belongs to TCP protocol package. In practice, it supports binary
Protocol and Web Protocol
. In this article, we will look at the HTTP web protocol and the messages that can be sent to OPC UA.
As mentioned above, OPC UA also defines the message format used on the HTTP protocol. The minimum configuration for the operation of this protocol is to use one client and one web server for easier networking in one LAN. In the first example with the source code, we will show the implementation of the web server on the ESP8266 platform, where we can control the individual GPIO pins of this microcontroller in the NodeMCU (ESP8266-12E) version through a computer browser with properly formatted HTTP query per page (IP address) ESP8266.
Thus, the system user will be in the role of a client. An example from the SoftwareTools4Makers OPC library for NodeMCU contains an example that allows you to control GPIO pins D0 to D10 through a simple HTTP query in the form:
. For example, for IP address 192.168.1.2 and to enable D5 we will use the query:
. In case we do not want static / dynamic IP for query routing, we can also use mDNS service with user defined domain name in form:
. (.local is required for the selected domain name to resolve it correctly).
UART monitor output for ESP8266 (D2 control):
The source code for the microcontroller can be found at:
. In the program it is necessary to change the access data to the WiFi network in the function myNodeMcu.setup (). After downloading the program, it is possible to run HTTP queries to the IP address ESP8266 in the browser. ESP8266 does not provide any output to the user in the browser (in another implementation, it may contain data that it wants to sell to the client, depending on the specific usage example). The change only affects the digital outlet. The D2 terminal is connected to a build-in LED that can be operated immediately without the need for external connection. The diode is called. Active LOW, ie signal 0 (LOW) switches it on and signal 1 (HIGH) switches it off. The command
enables the ESP8266-12E chip LED.
Source code has been tested on Arduino core version 2.5.2 for ESP8266. More interesting projects interested in Arduino, ESP8266, ESP32 can be found on my website:
. Examples of additional boards (Arduino + Ethernet, ESP32) will be added later, including client implementations with the transfer of specific data (sensors, data). We will also show you various custom implementations with cross communication. OPC UA architecture can also be implemented in other systems with REST API, SCADA, connection to external PLC systems etc.
Arduino and website programmer