Skip to main content

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

  1. Navigate to System Settings
  2. Note camera IP address (e.g., 10.250.0.100)
  3. 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

RequirementCameraTarget DeviceNotes
IP Range10.250.0.10010.250.0.xxxMust be same subnet
Subnet Mask255.255.255.0255.255.255.0Standard configuration
Port Access49155 (example)49155 (example)Avoid reserved ports
FirewallAllow TCP trafficAllow TCP trafficBoth directions

Step 2: Access Node-RED Editor

2.1 Navigate to IO Block

  1. Click "IO Block" in recipe breadcrumb menu, OR
  2. Select "Configure I/O" from Recipe Editor

2.2 Open Node-RED Editor

  1. Click Configure IO to enter Node-RED flow editor
  2. 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

  1. Locate "tcp in" node in the left panel (Network section)
  2. Drag "tcp in" node onto the flow canvas
  3. Double-click node to configure

3.2 Configure TCP Input Settings

Node Configuration:

SettingValueDescription
TypeListen onCamera acts as server
Port49155Port camera listens on
Data modeStreamContinuous data flow
Data typeUTF8Text-based communication
Topic(optional)Message categorization

3.3 TCP Input Configuration Steps

  1. Server Configuration:
    • Select "Listen on port" (server mode)
    • Enter port number (e.g., 49155)
  2. Data Handling:
    • Data mode: Select "Stream" for continuous data
    • Data type: Choose "UTF8" for text or "Buffer" for binary
  3. Advanced Settings:
    • New line character: Leave blank unless specific delimiter needed
    • Topic: Optional message routing identifier
  4. Click Done to save configuration

3.4 Port Selection Guidelines

Port RangeUsageRecommendation
1-1023System reservedAvoid
1024-49151Registered portsCheck availability
49152-65535Dynamic/privateRecommended

Step 4: Configure TCP Output (Send Data)

4.1 Add TCP Output Node

  1. Locate "tcp out" node in the left panel (Network section)
  2. Drag "tcp out" node onto the flow canvas
  3. Double-click node to configure

image.png

4.2 Configure TCP Output Settings

Node Configuration:

SettingValueDescription
TypeConnect toCamera acts as client
Host192.168.0.200Target device IP address
Port49155Target device port
ModeClientOutbound connection

4.3 TCP Output Configuration Steps

  1. Connection Settings:
    • Type: Select "Connect to" (client mode)
    • Host: Enter target device IP address
    • Port: Enter target device port number
  2. Connection Options:
    • Mode: Keep as "Client"
    • End connection: Configure based on use case
  3. Data Format:
    • Base64: Usually disabled for text data
    • TLS: Enable only if secure connection required
  4. 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:

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

  1. Double-click inject node
  2. Configure settings:
    • Name: "Send Message"
    • Payload: Timestamp
    • Topic: (leave empty)
  3. Click Done

5.3 Configure Function Node

The function node will format your outgoing message:

msg.payload = "Hello from OV80i camera";
return msg;

  1. Double-click function node
  2. Copy code above into "On Message" tab
  3. Name: "Format Message"
  4. 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 TypeFormatExample
Simple textPlain string"Hello from camera"
Status updatesText with info"STATUS: READY"
Data valuesKey-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

  1. Click Deploy button (top-right corner)
  2. Verify deployment success message
  3. 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

  1. Connect to camera TCP port
  2. Send test commands:
    • "STATUS" → Should receive status response
    • "TRIGGER" → Should trigger inspection
    • "INVALID" → Should handle unknown command

7.2.3 Monitor Debug Output

  1. Open Node-RED debug panel (right sidebar)
  2. Send test messages via TCP
  3. Verify debug output shows:
    • Incoming messages
    • Processing results
    • Outgoing responses

7.3 Validation Checklist

TestExpected ResultStatus
TCP connectionSuccessful connection to camera port
Message receptionDebug shows incoming messages
Message processingFunction node processes correctly
Response sendingTarget device receives responses
Error handlingInvalid messages handled gracefully

Step 8: Integration with Inspection System

8.1 Connect to Inspection Triggers

Link TCP communication with inspection workflow:

  1. Add "All Block Outputs" node (if not already present)
  2. Connect inspection results to TCP output
  3. 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

ProblemSymptomsSolution
Cannot connectRed status indicatorCheck IP address and port
Connection dropsIntermittent yellow statusVerify network stability
Timeout errorsDelayed responsesAdjust timeout settings
Port conflictsConnection refusedUse different port number

9.2 Data Transmission Issues

ProblemSymptomsSolution
No data receivedDebug shows empty messagesCheck data format settings
Corrupted dataGarbled text in debugVerify encoding (UTF8/Buffer)
Message lossMissing messagesCheck network stability
Large message issuesTruncated dataUse shorter messages

9.3 Debug Techniques

Systematic troubleshooting:

  1. Enable debug nodes at each step
  2. Monitor Node-RED logs for errors
  3. Test with simple TCP clients first
  4. 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:

  1. Test with your external systems using the established connection
  2. Customize message formats for your specific needs
  3. Add more complex logic as your requirements grow
  4. Consider other communication methods if TCP doesn't meet all needs

🔗 See Also

For high-throughput applications:

  1. Reduce message frequency
  2. Batch multiple messages
  3. Use binary format for large data
  4. Implement compression

Debug Techniques

Systematic troubleshooting:

  1. Enable debug nodes at each step
  2. Monitor Node-RED logs for errors
  3. Use network monitoring tools (Wireshark)
  4. 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:

  1. Integrate with your external systems using the established protocol
  2. Implement comprehensive error handling for production use
  3. Set up logging and monitoring for system health
  4. Consider security enhancements for production deployment

🔗 See Also