TCP Communication Setup
This guide shows you how to configure TCP communication between your OV80i camera and external devices using Node-RED. Use TCP communication for real-time data exchange, remote control, or integration with custom applications and systems.
When to Use TCP Communication: Real-time data streaming, custom application integration, bidirectional communication with external systems, high-frequency data exchange, or when HTTP/REST APIs are not suitable.
Prerequisites
- OV80i camera system set up and connected
- Target device/system with TCP communication capability
- Network connectivity between camera and target device
- Basic understanding of IP addresses and port numbers
- Active recipe configured (imaging and inspection setup complete)
Step 1: Verify Network Configuration
1.1 Check Camera IP Address
- Navigate to System Settings
- Note camera IP address (e.g., 10.250.0.100)
- Verify subnet mask and network configuration
1.2 Confirm Target Device Network
Ensure network compatibility:
- Same subnet: Camera and target device must be on the same network range
- Accessible ports: Target device ports must not be blocked by firewalls
- Network connectivity: Test with ping command if possible
1.3 Network Requirements
Requirement | Camera | Target Device | Notes |
---|---|---|---|
IP Range | 10.250.0.100 | 10.250.0.xxx | Must be same subnet |
Subnet Mask | 255.255.255.0 | 255.255.255.0 | Standard configuration |
Port Access | 49155 (example) | 49155 (example) | Avoid reserved ports |
Firewall | Allow TCP traffic | Allow TCP traffic | Both directions |
Step 2: Access Node-RED Editor
2.1 Navigate to IO Block
- Click "IO Block" in recipe breadcrumb menu, OR
- Select "Configure I/O" from Recipe Editor
2.2 Open Node-RED Editor
- Click
Configure IO
to enter Node-RED flow editor - Verify Node-RED interface loads properly
Checkpoint: You should see the Node-RED flow editor with node palette on the left.
Step 3: Configure TCP Input (Receive Data)
3.1 Add TCP Input Node
- Locate "tcp in" node in the left panel (Network section)
- Drag "tcp in" node onto the flow canvas
- Double-click node to configure
3.2 Configure TCP Input Settings
Node Configuration:
Setting | Value | Description |
---|---|---|
Type | Listen on | Camera acts as server |
Port | 49155 | Port camera listens on |
Data mode | Stream | Continuous data flow |
Data type | UTF8 | Text-based communication |
Topic | (optional) | Message categorization |
3.3 TCP Input Configuration Steps
- Server Configuration:
- Select "Listen on port" (server mode)
- Enter port number (e.g., 49155)
- Data Handling:
- Data mode: Select "Stream" for continuous data
- Data type: Choose "UTF8" for text or "Buffer" for binary
- Advanced Settings:
- New line character: Leave blank unless specific delimiter needed
- Topic: Optional message routing identifier
- Click
Done
to save configuration
3.4 Port Selection Guidelines
Port Range | Usage | Recommendation |
---|---|---|
1-1023 | System reserved | Avoid |
1024-49151 | Registered ports | Check availability |
49152-65535 | Dynamic/private | Recommended |
Step 4: Configure TCP Output (Send Data)
4.1 Add TCP Output Node
- Locate "tcp out" node in the left panel (Network section)
- Drag "tcp out" node onto the flow canvas
- Double-click node to configure
4.2 Configure TCP Output Settings
Node Configuration:
Setting | Value | Description |
---|---|---|
Type | Connect to | Camera acts as client |
Host | 192.168.0.200 | Target device IP address |
Port | 49155 | Target device port |
Mode | Client | Outbound connection |
4.3 TCP Output Configuration Steps
- Connection Settings:
- Type: Select "Connect to" (client mode)
- Host: Enter target device IP address
- Port: Enter target device port number
- Connection Options:
- Mode: Keep as "Client"
- End connection: Configure based on use case
- Data Format:
- Base64: Usually disabled for text data
- TLS: Enable only if secure connection required
- Click
Done
to save configuration
Step 5: Create Communication Flow
5.1 Build the Complete Flow
Create a flow that can both send and receive TCP data:
- Add these nodes to your canvas:
- Inject node (for triggering messages)
- Function node (for message processing)
- TCP Out node (for sending data)
- TCP In node (for receiving data)
- Debug nodes (for monitoring)
5.2 Configure Inject Node
- Double-click inject node
- Configure settings:
- Name: "Send Message"
- Payload: Timestamp
- Topic: (leave empty)
- Click
Done
5.3 Configure Function Node
The function node will format your outgoing message:
msg.payload = "Hello from OV80i camera";
return msg;
- Double-click function node
- Copy code above into "On Message" tab
- Name: "Format Message"
- Click
Done
5.4 Wire the Connections
Connect nodes in this order:
Outgoing flow:
- Inject → Function → TCP Out
- Function → Debug (to see outgoing messages)
Incoming flow:
- TCP In → Debug (to see incoming messages)
5.5 Complete Flow Structure
Your final flow should have:
- Inject connected to Function
- Function connected to both TCP Out and Debug
- TCP In connected to separate Debug node
Result: You can send messages by clicking the inject button and see both outgoing and incoming messages in the debug panel.
Step 6: Configure Message Format
6.1 Define Message Format
Keep message structure simple:
Message Type | Format | Example |
---|---|---|
Simple text | Plain string | "Hello from camera" |
Status updates | Text with info | "STATUS: READY" |
Data values | Key-value format | "TEMPERATURE: 25.5" |
6.2 Custom Message Examples
You can modify the function node for different message types:
Simple status message:
msg.payload = "Camera Ready";
return msg;
Timestamp message:
msg.payload = "Time: " + new Date().toLocaleString();
return msg;
Data with values:
msg.payload = "INSPECTION_COUNT: 42";
return msg;
Step 7: Deploy and Test Configuration
7.1 Deploy Node-RED Flow
- Click
Deploy
button (top-right corner) - Verify deployment success message
- Check node status indicators:
- Green dot: Successfully connected
- Red dot: Connection error
- Yellow dot: Attempting connection
7.2 Test TCP Communication
7.2.1 Basic Connectivity Test
Using command line tools:
# Test TCP connection (Linux/Mac)
telnet [camera-ip] [port]
# Example: telnet 10.250.0.100 49155
# Test with netcat
nc [camera-ip] [port]
# Example: nc 10.250.0.100 49155
Windows PowerShell:
Test-NetConnection -ComputerName 10.250.0.100 -Port 49155
7.2.2 Send Test Messages
- Connect to camera TCP port
- Send test commands:
- "STATUS" → Should receive status response
- "TRIGGER" → Should trigger inspection
- "INVALID" → Should handle unknown command
7.2.3 Monitor Debug Output
- Open Node-RED debug panel (right sidebar)
- Send test messages via TCP
- Verify debug output shows:
- Incoming messages
- Processing results
- Outgoing responses
7.3 Validation Checklist
Test | Expected Result | Status |
---|---|---|
TCP connection | Successful connection to camera port | ☐ |
Message reception | Debug shows incoming messages | ☐ |
Message processing | Function node processes correctly | ☐ |
Response sending | Target device receives responses | ☐ |
Error handling | Invalid messages handled gracefully | ☐ |
Step 8: Integration with Inspection System
8.1 Connect to Inspection Triggers
Link TCP communication with inspection workflow:
- Add "All Block Outputs" node (if not already present)
- Connect inspection results to TCP output
- Format inspection data for TCP transmission
8.2 Inspection Data Integration
Function node to process inspection results:
// Get inspection results from All Block Outputs
const results = msg.payload;
// Extract key information
const inspectionSummary = {
result: results.pass ? "PASS" : "FAIL",
timestamp: new Date().toISOString(),
processing_time: results.processing_time,
roi_count: results.roi_results ? results.roi_results.length : 0
};
// Format for TCP transmission
msg.payload = JSON.stringify(inspectionSummary);
return msg;
8.3 Bidirectional Control
Enable remote control via TCP:
// Handle remote commands
const command = msg.payload.toString().toUpperCase();
switch(command) {
case "START_INSPECTION":
// Trigger inspection sequence
global.set("trigger_inspection", true);
msg.payload = "INSPECTION_STARTED";
break;
case "STOP_INSPECTION":
// Stop inspection sequence
global.set("trigger_inspection", false);
msg.payload = "INSPECTION_STOPPED";
break;
case "CHANGE_RECIPE":
// Recipe change logic
msg.payload = "RECIPE_CHANGED";
break;
}
return msg;
Step 9: Troubleshooting Common Issues
9.1 Connection Problems
Problem | Symptoms | Solution |
---|---|---|
Cannot connect | Red status indicator | Check IP address and port |
Connection drops | Intermittent yellow status | Verify network stability |
Timeout errors | Delayed responses | Adjust timeout settings |
Port conflicts | Connection refused | Use different port number |
9.2 Data Transmission Issues
Problem | Symptoms | Solution |
---|---|---|
No data received | Debug shows empty messages | Check data format settings |
Corrupted data | Garbled text in debug | Verify encoding (UTF8/Buffer) |
Message loss | Missing messages | Check network stability |
Large message issues | Truncated data | Use shorter messages |
9.3 Debug Techniques
Systematic troubleshooting:
- Enable debug nodes at each step
- Monitor Node-RED logs for errors
- Test with simple TCP clients first
- Verify network connectivity with ping
Success! Your TCP Communication is Ready
Your TCP communication system can now:
- Send and receive data between camera and external devices
- Process simple messages for basic communication
- Monitor data flow with debug nodes
- Handle basic network communication for your applications
Ongoing Maintenance
Regular System Checks
- Monitor connection stability over time
- Verify data transmission works consistently
- Check debug logs for any error patterns
- Test communication after network changes
Next Steps
After setting up basic TCP communication:
- Test with your external systems using the established connection
- Customize message formats for your specific needs
- Add more complex logic as your requirements grow
- Consider other communication methods if TCP doesn't meet all needs
🔗 See Also
- MQTT Communication Setup
- RS-232 Communication Setup
- Connect to PLC (Ethernet/IP, PROFINET)
- Node-RED Basics
- Overview Node-RED Custom Blocks
- IP & Network Discovery Failures
For high-throughput applications:
- Reduce message frequency
- Batch multiple messages
- Use binary format for large data
- Implement compression
Debug Techniques
Systematic troubleshooting:
- Enable debug nodes at each step
- Monitor Node-RED logs for errors
- Use network monitoring tools (Wireshark)
- Test with simple TCP clients first
Success! Your TCP Communication is Ready
Your TCP communication system can now:
- Send and receive data between camera and external devices
- Process commands for remote control
- Transmit inspection results in real-time
- Handle errors gracefully with proper error handling
- Integrate with production systems for automated workflows
Ongoing Maintenance
Regular System Checks
- Monitor connection stability over time
- Verify data integrity in production
- Update security configurations as needed
- Optimize performance based on usage patterns
Performance Monitoring
- Track message throughput and latency
- Monitor error rates and connection failures
- Analyze data patterns for optimization opportunities
Next Steps
After setting up TCP communication:
- Integrate with your external systems using the established protocol
- Implement comprehensive error handling for production use
- Set up logging and monitoring for system health
- Consider security enhancements for production deployment