MQTT Communication Setup
This guide shows you how to configure MQTT communication between your OV80i camera and external devices using Node-RED. MQTT enables lightweight, reliable messaging for IoT applications and remote device communication.
When to Use MQTT Communication: IoT device integration, remote monitoring systems, publish/subscribe messaging patterns, low-bandwidth environments, distributed sensor networks, or when you need reliable message delivery with automatic reconnection.
Prerequisites
- OV80i camera system set up and connected
- Network connectivity between camera and MQTT broker
- MQTT broker available (local or cloud-based)
- Basic understanding of MQTT concepts (topics, publish/subscribe)
- Active recipe configured on the camera
MQTT Communication Overview
MQTT Key Concepts:
- Broker: Central server that routes messages between clients
- Topics: Message categories (e.g., "camera/status", "commands/trigger")
- Publish: Send messages to a topic
- Subscribe: Receive messages from a topic
- QoS: Quality of Service levels (0, 1, 2)
Step 1: Verify Network Configuration
1.1 Check Camera Network Settings
- Navigate to System Settings
- Note camera IP address (e.g., 10.250.0.100)
- Verify network connectivity to MQTT broker
1.2 MQTT Broker Requirements
Ensure MQTT broker accessibility:
- Same network: Camera must reach broker IP address
- Port access: Default MQTT port 1883 (or 8883 for TLS)
- Authentication: Username/password if broker requires it
- Firewall: Allow MQTT traffic on required ports
1.3 Network Requirements
Component | IP Address | Port | Notes |
---|---|---|---|
Camera | 10.250.0.100 | N/A | Must reach broker |
MQTT Broker | 10.250.0.200 | 1883 | Standard MQTT port |
Client Devices | 10.250.0.xxx | Variable | Any devices subscribing |
Step 2: Access Node-RED Editor
2.1 Navigate to IO Block
- Open your active recipe in Recipe Editor
- Click "IO Block" in breadcrumb menu
- Click "Configure IO" to enter Node-RED editor
2.2 Verify MQTT Nodes Available
Check Node-RED palette for MQTT nodes:
- mqtt in - Subscribe to MQTT topics
- mqtt out - Publish to MQTT topics
Checkpoint: You should see MQTT nodes in the Network section of the left panel.
Step 3: Configure MQTT Broker Connection
3.1 Add MQTT Broker Configuration
- Drag "mqtt in" node onto canvas (for initial setup)
- Double-click the node to open configuration
- Click pencil icon next to Server field
- Click "Add new mqtt-broker"
3.2 Configure Broker Settings
Basic Broker Configuration:
Setting | Value | Description |
---|---|---|
Name | Camera MQTT Broker | Descriptive identifier |
Server | 192.168.0.200 | MQTT broker IP address |
Port | 1883 | Standard MQTT port |
Protocol | MQTT V3.1.1 | Recommended version |
Client ID | (auto-generate) | Leave blank for automatic |
3.3 Authentication Settings (If Required)
If broker requires authentication:
Setting | Description |
---|---|
Username | MQTT broker username |
Password | MQTT broker password |
Use TLS | Enable for secure connections (port 8883) |
3.4 Advanced Settings
Connection Options:
Setting | Recommended Value | Description |
---|---|---|
Keep Alive | 60 seconds | Heartbeat interval |
Clean Session | True | Start fresh each connection |
Auto Connect | True | Reconnect automatically |
3.5 Save Broker Configuration
- Click "Add" to save broker settings
- Click "Done" to close node configuration
- Broker configuration is now available for all MQTT nodes
Step 4: Configure MQTT Input (Subscribe)
4.1 Set Up MQTT In Node
- Select the "mqtt in" node you added
- Double-click to configure
- Configure subscription settings:
4.2 MQTT In Configuration
Subscription Settings:
Setting | Example Value | Description |
---|---|---|
Server | Camera MQTT Broker | Select configured broker |
Topic | camera/commands | Topic to subscribe to |
QoS | 0 | Message delivery quality |
Output | auto-detect | Message format |
Name | Command Listener | Node identifier |
4.3 Topic Naming Conventions
Recommended topic structure:
Purpose | Topic Example | Usage |
---|---|---|
Commands | camera/commands | Receive control commands |
Status requests | camera/status/request | Status information requests |
Configuration | camera/config | Configuration changes |
4.4 Configure Message Processing
- Add "debug" node to monitor incoming messages
- Connect: MQTT In → Debug
- Configure debug node to show complete message
Step 5: Configure MQTT Output (Publish)
5.1 Add MQTT Out Node
- Drag "mqtt out" node onto canvas
- Double-click to configure
- Select same broker configuration
5.2 MQTT Out Configuration
Publishing Settings:
Setting | Example Value | Description |
---|---|---|
Server | Camera MQTT Broker | Same broker as input |
Topic | camera/responses | Topic for camera responses |
QoS | 0 | Message delivery quality |
Retain | False | Don't store last message |
Name | Response Publisher | Node identifier |
5.3 Response Topic Structure
Recommended response topics:
Response Type | Topic Example | Usage |
---|---|---|
Status updates | camera/status | Camera status information |
Results | camera/results | Inspection results |
Acknowledgments | camera/ack | Command confirmations |
Step 6: Create Basic Communication Flow
6.1 Build Outgoing Message Flow
Create a flow to publish messages from the camera:
- Add "inject" node for triggering messages
- Add "function" node for message formatting
- Add "mqtt out" node for publishing
- Connect: Inject → Function → MQTT Out
6.2 Build Incoming Message Flow
Create a separate flow to receive messages:
- Add "mqtt in" node for subscribing
- Add "debug" node for monitoring
- Connect: MQTT In → Debug
6.3 Configure Inject Node
- Double-click inject node
- Configure settings:
- Name: "Send Test Message"
- Payload: Timestamp
- Topic: (leave empty)
- Click "Done"
6.4 Configure Function Node
Simple message formatting:
// Format outgoing message
msg.topic = "camera/status";
msg.payload = "Camera online - " + new Date().toISOString();
return msg;
- Double-click function node
- Copy code above into "On Message" tab
- Name: "Format Message"
- Click "Done"
6.5 Configure MQTT Out Node
- Double-click mqtt out node
- Select broker: Camera MQTT Broker (configured earlier)
- Topic: (leave empty - set by function node)
- Name: "Publish Status"
- Click "Done"
6.6 Configure MQTT In Node
- Double-click mqtt in node
- Select broker: Camera MQTT Broker
- Topic:
camera/commands
- Name: "Command Listener"
- Click "Done"
6.7 Configure Debug Node
- Double-click debug node
- Output: Complete msg object
- Name: "Incoming Messages"
- Click "Done"
6.8 Final Flow Structure
Your complete flow should be:
Outgoing: Inject → Function → MQTT Out Incoming: MQTT In → Debug
Step 7: Deploy and Test Configuration
7.1 Deploy Flow
- Click "Deploy" button (top-right corner)
- Verify deployment success message
- Check node status indicators:
- Green dot: Connected to broker
- Red dot: Connection failed
- Yellow dot: Connecting
7.2 Test Internal Communication
Test the camera's MQTT publishing:
- Click inject button to send test message
- Verify MQTT Out node shows activity
- Check debug panel if you have external messages
7.3 External Testing (Optional)
Test with external MQTT client to send commands to camera:
Using command line tools:
# Send a test command to the camera
mosquitto_pub -h 10.250.0.100 -t "camera/commands" -m "test_command"
Expected result: Debug node should show the incoming message in Node-RED debug panel.
7.4 Verify Communication
Check these aspects:
Test | Expected Result | Status |
---|---|---|
Broker connection | Green status on MQTT nodes | ☐ |
Message publishing | Inject triggers MQTT Out successfully | ☐ |
Message reception | Debug shows external messages | ☐ |
Reconnection | Auto-reconnect after network interruption | ☐ |
Step 8: Troubleshooting MQTT Issues
8.1 Connection Problems
Problem | Symptoms | Solution |
---|---|---|
Cannot connect to broker | Red status indicators | Check broker IP and port |
Authentication failure | Connection refused | Verify username/password |
Network timeouts | Yellow connecting status | Check network connectivity |
Firewall blocking | No connection attempt | Open MQTT ports |
8.2 Message Issues
Problem | Symptoms | Solution |
---|---|---|
No messages received | Debug shows nothing | Check topic subscriptions |
Messages not publishing | External clients see nothing | Verify publish topics |
Message format errors | Parsing failures | Use simple text messages |
Lost messages | Intermittent delivery | Check broker connection |
8.3 Performance Issues
Problem | Symptoms | Solution |
---|---|---|
High latency | Delayed message delivery | Check broker performance |
Connection drops | Frequent reconnections | Adjust keep-alive settings |
Message flooding | Broker overload | Implement message throttling |
8.4 Debug Techniques
Systematic troubleshooting:
- Check broker connection status in Node-RED
- Monitor Node-RED debug panel for message flow
- Use simple text messages before complex data
- Verify network connectivity with ping
- Test with basic topics before advanced flows
Success! Your MQTT Communication is Ready
Your MQTT communication system can now:
- Connect to MQTT brokers with proper authentication
- Subscribe to topics for receiving commands and data
- Publish messages for status updates and responses
- Handle JSON message formats for structured communication
- Automatically reconnect after network interruptions
- Support multiple QoS levels for different message priorities
Ongoing Maintenance
Regular System Checks
- Monitor broker connection status in Node-RED
- Verify message delivery with test messages
- Check broker logs for any error patterns
- Update authentication credentials as needed
Performance Monitoring
- Track message latency and delivery times
- Monitor broker resource usage for scalability
- Analyze topic usage patterns for optimization
- Review QoS settings based on actual requirements
Next Steps
After setting up basic MQTT communication:
- Implement specific messaging workflows for your application
- Set up topic hierarchies for organized communication
- Add security measures like TLS encryption
- Integrate with external systems using established MQTT protocols
- Create monitoring dashboards for system health
Related Documentation
- Tutorial: Trigger Using MQTT Communication
- How-To: TCP Communication Setup
- How-To: RS-232 Communication Setup
- Tutorial: PLC Integration Complete Walkthrough
- Reference: Node-RED Logic Blocks Guide