Introduction: OPC UA - (ESP8266, ESP32, Arduino + Ethernet)
In project you can use most common platforms like: Arduino with Ethernet shield/module from Wiznet family, for instance: Wiznet W5100, Wiznet W5500. For WiFi connectivity and also with option of using secure protocol, and another verify methods like verification of client certificate, etc..
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Architecture OPC UA
OPC-UA has existed since 2008. It is a server architecture that supports multiplatform applications.The simplest implementation is connecting clients to a web server that responds to client queries and receives GET data with a request.Architecture is used in microprocessor communication, automation systems with PLC, simple sensor networks.In an advanced implementation, it is also possible to use an HTTPS connection to verify the WebServer / Client / Server certificate.Demonstration implementation shows easy connectivity between boards on the ESP8266 platform using an HTTP web server.
Step 2: Types of Implemented Servers
In this project, there are 2 types of supported webservers.
The ESP8266 or ESP32 server board also uses the AP access point implementation. The connected devices are thus in one network with the server and the network is encrypted under WPA / WPA2 - PSK.ESP8266 broadcasts a WiFi network called ESP_WiFi with the password thereisnospoon , the server address is: 192.168.4.1 on port 80, assigning an address from the range 192.168.4.X s 24-bit network mask.The principle of functionality is simple based on HTTP request to the server. Multiple values (parameters) can be received at the same time. You must accept each parameter and separate it with & in the query.
Second option is to use ESP8266, ESP32 or Arduino with Ethernet as STATION to connecting it to existing LAN network where OPC UA network can run too!
At screenshot you can see output of webserver (received datas from clients)
- / - The root location (192.168.4.1), the page can be used by a client on a computer, other device, visualizes the last value from the client in the title
- /data/ - data receiving page, expecting sensor_reading with parameter value
- /get_data/ - Subscriber Last Measured Response Page
Step 3: Types of Implemented Clients
Types of clients implemented in the project:
- Publish_Client - sends data from ADC converter to server, prints received server response - acknowledges receipt of sent data
- Publish_Client_UDP - send data from ADC converter to server, skip server response (process it, do not write received response, do not work with it)
- Subscriber_Client - performs an HTTP query to the server - the server responds with a received value from the client, for example, the value can be a temperature. It is possible to work with the value and use it (ventilation, boiler switching, relay)
Screenshots are for Publish_Client and for Subscriber_Client example output in Serial monitor.
Step 4: Source Codes for OPC UA Architecture
There are available source codes for clients for all platforms (ESP32, ESP8266, Arduino with Ethernet module): https://arduino.php5.sk/opc-ua-esp8266.php?lang=en
Codes for OPC UA webservers for all platforms (ESP32, ESP8266, Arduino) are not available for free. If you want to buy them, contact me for more informations, payment method: firstname.lastname@example.org
Step 5: OPC-UA Communication IRL
In this video you can see OPC-UA communication with ESP8266 as webserver, one ESP8266 as Publisher. Computer on Windows with Chrome browser is showing root directory and /get_data/ directory as Subscriber.
Step 6: Options for Encoding
Datas can be sent as raw data in POST / GET request, or they can be encoded to JSON or SOAP (xml) format. Format can be send over POST request. Webserver will handle that connection and it will parse datas. For instance in pictures you can see how data looks like when they are JSON and XML (SOAP) encoded. SOAP is OPC-UA Web service main format! Pictures are from UART of OPC-UA webserver running at Arduino + Ethernet or ESP32 or ESP8266. You can see how webserver receives datas in POST payload.