Rela AIRela AI Docs
Integrations

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.sh

Access the web interface: http://localhost:8080

Default credentials: admin / hivemq

Step 2: Configure the OPC UA bridge

In the HiveMQ Edge web interface:

  1. Go to Protocol Adapters → OPC UA → Add New
  2. 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
  3. Payload Format: select OPC UA Pub/Sub JSON if available, or JSON as an alternative
  4. 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:

  1. Go to Bridges → MQTT → Add New
  2. 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)
  3. Save and Start

Step 4: Verify

# From another machine, subscribe to the topic
mosquitto_sub -h broker.hivemq.com -t "north-plant/gateway-line1" -v

You should see JSON messages every time a value changes on the PLC.

Step 5: Configure Rela-ai

  1. In the dashboard, create a source with protocol OPC UA → Via Gateway MQTT
  2. Configure broker URL and topic
  3. 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.

On this page