Gateway with HiveMQ Edge
Guide to configure HiveMQ Edge as an OPC UA to MQTT bridge to connect PLCs with Rela-ai.
What is HiveMQ Edge
HiveMQ Edge is free software that turns your Linux computer (or Raspberry Pi) into an industrial gateway. It has a native OPC UA to MQTT bridge — no additional plugins needed.
Advantages:
- Free and open source
- Native OPC UA bridge (no plugins)
- Web interface for configuration
- Support for Modbus, S7, EtherNet/IP in addition to OPC UA
- Local buffer if internet connection is lost
What you need
- Linux computer (Ubuntu 20.04+, Raspberry Pi OS, or similar)
- Java 11+ installed
- Ethernet cable for the PLC network
- Internet access
- PLC data: IP, OPC UA port, Node IDs
Step 1: Install HiveMQ Edge
# Download the latest version
wget https://github.com/hivemq/hivemq-edge/releases/latest/download/hivemq-edge.zip
# Unzip
unzip hivemq-edge.zip
cd hivemq-edge
# Check Java
java -version # Must be 11+
# Start
./bin/run.shAccess the web interface: http://localhost:8080
Default credentials: admin / hivemq
Step 2: Configure the OPC UA bridge
In the HiveMQ Edge web interface:
- Go to Protocol Adapters → OPC UA → Add New
- Configure:
- Name:
PLC-Line1(descriptive name) - Server URL:
opc.tcp://<PLC-IP>:4840 - Publish Topic:
north-plant/gateway-line1 - Subscriptions: add the Node IDs you want to monitor
- Name:
- Payload Format: select OPC UA Pub/Sub JSON if available, or JSON as an alternative
- Click Save and then Start
Step 3: Configure remote MQTT bridge
If your MQTT broker is on the internet (not local), configure an MQTT bridge:
- Go to Bridges → MQTT → Add New
- Configure:
- Remote Broker:
mqtt://broker.hivemq.com:1883(or your broker) - Username/Password: broker credentials
- Topics: map the local topic to the remote one (usually the same)
- Remote Broker:
- Save and Start
Step 4: Verify
# From another machine, subscribe to the topic
mosquitto_sub -h broker.hivemq.com -t "north-plant/gateway-line1" -vYou should see JSON messages every time a value changes on the PLC.
Step 5: Configure Rela-ai
- In the dashboard, create a source with protocol OPC UA → Via Gateway MQTT
- Configure broker URL and topic
- Rela-ai receives the data automatically
Payload format
HiveMQ Edge sends data in JSON format. If the format is not native OPC UA Pub/Sub JSON, you can use a Data Policy in HiveMQ Edge to transform the payload before sending it.
Expected format by Rela-ai:
{
"MessageType": "ua-data",
"PublisherId": "PLC-Linea1",
"Messages": [{
"Payload": {
"Temperature": {"Value": 75.5, "StatusCode": 0},
"Pressure": {"Value": 1.2, "StatusCode": 0}
}
}]
}Tips
- Auto-start: Configure HiveMQ Edge as a systemd service so it starts automatically on boot.
- Multiple PLCs: You can add multiple OPC UA adapters, one per PLC, publishing to different topics.
- Monitoring: The web interface shows real-time metrics: messages/second, active connections, errors.
- OPC UA Security: Configure certificates and authentication on the adapter if the PLC requires it.
Gateway with Node-RED (Raspberry Pi)
Step-by-step guide to configure a Raspberry Pi with Node-RED as an OPC UA to MQTT gateway for Rela-ai.
Outgoing Webhooks
Send real-time notifications to external systems when events occur in Rela AI — task created, alarm triggered, maintenance completed. With automatic retries and delivery tracking.