Configure MQTT client connection for IoT devices, cloud platforms, or inter-system communication using the lightweight publish/subscribe protocol.
What You'll Learn
- Configure MQTT client
- Subscribe to topics
- Publish tag values
- Map topics to tags
Prerequisites
- MQTT broker available (or use public test broker)
- Basic understanding of MQTT topics
Step 1: Configure MQTT Client
- Navigate to Devices → Channels
- Create channel:
- Name:
MQTTClient
- Protocol:
MQTT Client
- Settings:
- Broker URL:
test.mosquitto.org
(or your broker) - Port: 1883 (or 8883 for SSL)
- Client ID:
FrameworX_001
- Keep Alive: 60 seconds
- Broker URL:
- Name:
Step 2: Set Authentication (if required)
For secured brokers:
- Username: Your username
- Password: Your password
- SSL/TLS: Enable if using port 8883
- Certificates: Browse to certificate files
Step 3: Subscribe to Topics
- Go to Devices → Nodes
- Create subscription node:
- Name:
IoT_Sensors
- Channel:
MQTTClient
- Subscribe Topic:
sensors/+/temperature
- QoS: 1
- Name:
The '+' wildcard subscribes to all sensors.
Step 4: Create Points for Subscribed Data
- Navigate to Devices → Points
- Add points for each expected topic:
Temperature Sensor:
- Name:
Sensor1_Temp
- Node:
IoT_Sensors
- Topic:
sensors/sensor1/temperature
- Data Type: Double
- JSON Path:
$.value
(if JSON payload)
Humidity Sensor:
- Name:
Sensor1_Humidity
- Node:
IoT_Sensors
- Topic:
sensors/sensor1/humidity
- Data Type: Double
Step 5: Publish Tag Values
- Create publish node:
- Name:
SCADA_Publisher
- Channel:
MQTTClient
- Publish Mode: On Change
- Name:
- Configure published points:
- Tag: Select tag to publish
- Topic:
scada/line1/production
- QoS: 1
- Retain: True (optional)
Step 6: JSON Payload Handling
For complex JSON:
json
{
"deviceId": "sensor1",
"temperature": 22.5,
"humidity": 45,
"timestamp": "2024-01-01T12:00:00Z"
}
Configure point:
- JSON Path for temperature:
$.temperature
- JSON Path for humidity:
$.humidity
- JSON Path for timestamp:
$.timestamp
Step 7: Test Connection
- Start Runtime
- Open Devices → Monitor
- Use MQTT client tool (like MQTT Explorer) to:
- Publish test messages
- Verify FrameworX publishes
Sparkplug B Configuration
For industrial MQTT:
- Select Protocol:
MQTT SparkplugB
- Configure:
- Group ID:
Plant1
- Edge Node ID:
Line1
- Device ID:
PLC1
- Group ID:
Best Practices
- Use meaningful topic hierarchies
- Set appropriate QoS levels
- Enable retain for configuration data
- Implement Last Will and Testament
- Use SSL/TLS in production
Next Steps
- [AWS IoT Core Connector] - Cloud integration
- [Enrich Data & Scripts] - Process MQTT data
- [Secure & Deploy] - Production security