Warning
Final Testing & Documentation In Progress
The core server functionality is implemented and the API is approaching stability. Final testing, documentation, and project examples are still in progress, and minor API changes may occur before the v1.0.0 release.
rOpen62541 is an open-source B4R library wrapper for the industrial open62541 OPC UA protocol stack, specifically optimized for the ESP32-S3 Dual-Core architecture.
It provides thread-safe cross-core communication, dynamic string-node creation with a flat hierarchy, and type-agnostic runtime write diagnostics.
rOpen62541 intentionally supports a single application root object, Factory_Floor, with a flat collection of application nodes. Hierarchical folders are outside the scope of the current B4R wrapper.---
Author's Note & Personal Context (Click to expand)
This library was developed purely for personal educational use, born out of a desire to dive deep into industrial connectivity and tackle the challenging feat of wrapping the open62541 stack for B4R. It wasn't easy to build, but exploring cross-platform client integration — such as B4J with the PyBridge and opcua-asyncio or Node-RED — and seeing the dual-core hardware spring to life made it an incredibly rewarding project. Moving forward, this proof-of-concept server framework will serve as a foundational wireless gateway component for the author's open-source several MAKE projects.
What is OPC UA & What is it used for? (Click to expand)
OPC UA (Open Platform Communications Unified Architecture) is a robust, platform-independent, and highly secure industrial machine-to-machine (M2M) communication protocol framework widely deployed in Industry 4.0 / Industrial IoT (IIoT) environments. Unlike standard message-based IoT protocols (like MQTT), OPC UA provides a unified Address Space allowing devices to structurally expose complex object folders, variable data nodes, and custom tracking methods with rich data metadata. It is extensively used to interconnect hardware sensors, embedded controllers, PLCs, industrial SCADA systems, and high-level enterprise MES/ERP software architectures seamlessly over modern Ethernet/Wi-Fi networks.
- Server-Only Architecture: This library is dedicated exclusively to acting as an OPC UA Server data provider; it does not include client connection parsing capabilities.
- Proof of Concept & Learning Project: This framework was explicitly developed as a personal educational project to learn the foundational basics of OPC UA by creating a custom standalone hardware device from scratch.
- No Professional Intent: There is absolutely no intention for this codebase to be deployed in mission-critical environments, production facilities, or professional commercial installations.
Note: For a detailed breakdown of the underlying dual-core task design and memory synchronization layers, see the Developer Notes.
rOpen62541 uses a simple, flat node hierarchy. All application nodes reside inside a single namespace (Namespace 1) and are attached directly below the root folder object:
Objects (ns=0;i=85)
└── Factory_Floor (ns=1;s=Factory_Floor)
├── Temperature
├── Humidity
├── Pump1_Status
├── Production_Count
├── Trigger
└── System_AvailableRAM
Folders and additional dynamic hierarchical object levels are not supported by the current B4R wrapper.
This is an intentional design choice to keep the B4R API simple, eliminate multi-namespace memory overhead, and minimize RAM usage on ESP32-class microcontrollers.
For applications requiring logical groupings or separating field data from diagnostic metrics, prefix naming should be used.
This mirrors the flat tag-naming approaches universally adopted in industrial PLCs, SCADA databases, and automation historians:
- Field Assets: Group components by physical location or machine ID (e.g., Tank1_Temperature, Pump2_Speed).
- System Metrics: Group microcontroller health stats together (e.g., System_AvailableRAM, System_Uptime).
Example B4R implementation:
' Industrial Field Assets
OPCUAServer.AddFloatNode("Tank1.Temperature", "Tank 1 Temperature", 22.5)
OPCUAServer.AddFloatNode("Tank1.Level", "Tank 1 Level", 75.0)
OPCUAServer.AddBooleanNode("Pump1.Status", "Pump 1 Status", False)
' Embedded System Metrics (Kept cleanly in Namespace 1)
OPCUAServer.AddIntNode("System.AvailableRAM", "Available RAM", 184320)
- Supported Hardware: Optimized for Espressif ESP32-S3 high-memory microcontrollers (specifically the N16R8 format featuring 16MB Flash and 8MB PSRAM).
- Network Layer: Requires standard embedded network
lwIPsocket frameworks to be initialized on boot.
This server implementation complies strictly with core industrial data-modeling specs and has been successfully verified across multiple desktop, terminal, and automation client ecosystems:
- B4J (Native Client) - Integration with OPC UA Client library for B4J.
- B4J with PyBridge - Working via Python-backend socket communication routing bridges PyBridge framework.
- opcua-commander - Validated using the interactive, keyboard-driven terminal curses explorer (TUI).
- Node.js OPC UA Stack — Working via simple TypeScript client example.
- Node-RED - Fully interoperable using the standard
node-red-contrib-opcuaflow palette node module.
Download the repository from GitHub.
- Copy the src sub-folder rOpen62541 into your B4R Additional Libraries folder, keeping the folder structure fully intact.
- Copy the src file rOpen62541.xml into your B4R Additional Libraries folder. Note: Read the B4R installation instructions.
The repository includes complete, ready-to-run environment folders demonstrating and testing specific implementation patterns:
- Go to the Project Examples Index - Explore runnable source code examples for Environment Simulation, Method Callbacks, Peripheral I/O Mapping, System Node ID lookups, and more.
The examples are designed to test the fundamental communication directions between the physical device, the OPC UA server, and external clients, like
- LED → OPC UA client → server → physical output
- Push-button → physical input → server → OPC UA client
- DHT22 → real sensor data → server → OPC UA client → Home Assistant
For detailed tutorials, API blueprints, and environment configurations, please visit our centralized documentation hub:
- Go to the Project Documentation Hub — Complete step-by-step guides covering Callbacks, Node IDs, Developer Notes, Functions, and Troubleshooting.
- rOpen62541 Library * MIT License as stated in the LICENSE file provided with rOpen62541.
- open62541 Library * Mozilla Public License v2.0 as stated in the LICENSE file provided with open62541.
- Developers, maintainers, and open-source contributors of the official open62541 architecture framework, providing an industrial-grade embedded C implementation of OPC UA.
- Developer of the open62541-121-esp32 repository, which served as the foundation for this B4R wrapper.
- Anywhere Software for the B4X suite of RAD development tools.
- Developer of the B4J library SS_OPCUAClient.
- AI for engineering collaboration.
Disclaimer
- All product names, logos, protocols, and brands are property of their respective owners.
- This B4R library is an independent open-source wrapper tracking standard open62541 architectures.
- It is neither officially endorsed nor maintained by the primary open62541 project core maintainers.
- This codebase represents a strict standalone proof-of-concept / learning exercise and is explicitly not intended for professional, commercial, or critical industrial application.
- This wrapper, its cross-core FreeRTOS mutex mappings, and its data type interceptor routines were designed and polished with the specialized interactive assistance of an AI engineering collaborator, achieving optimal compatibility with the B4R pre-compiler stack.
