Connect your Jetson AI vision system to the rest of your factory. Use MQTT to send real-time defect alerts, occupancy counts, and machine events to PLCs, SCADA systems, dashboards, and mobile apps — with sub-100ms latency.
What you will learn
- What MQTT is and why it is the standard for IoT/factory messaging
- How to publish AI detection events to an MQTT broker
- How to subscribe to topics from a dashboard, PLC, or app
- How to structure MQTT payloads for maximum compatibility
- How to set up a local Mosquitto broker (pre-installed on your kit)
Step 1 — Start the Mosquitto broker
# Mosquitto MQTT broker is pre-installed
sudo systemctl start mosquitto
sudo systemctl enable mosquitto # auto-start on boot
# Test it works
mosquitto_sub -t "test/#" -v &
mosquitto_pub -t "test/hello" -m "Jetson connected!"
Step 2 — Publish AI alerts from Python
import paho.mqtt.client as mqtt
import json, time
client = mqtt.Client("jetson-vision")
client.connect("localhost", 1883)
client.loop_start()
def publish_detection(camera_id, class_name, confidence, bbox):
payload = json.dumps({
"timestamp": time.time(),
"camera_id": camera_id,
"class": class_name,
"confidence": round(confidence, 3),
"bbox": bbox,
"alert": confidence > 0.85
})
client.publish(f"vision/{camera_id}/detection", payload)
# Call this every time a defect is detected:
publish_detection("cam1", "scratch", 0.92, [120, 80, 340, 210])
Step 3 — Subscribe from Node-RED dashboard
# Node-RED is pre-installed at http://localhost:1880
# Add an MQTT-in node, set broker to localhost:1883
# Topic: vision/+/detection
# Connect to a dashboard gauge, alert, or database node
Step 4 — Run the full MQTT demo
cd ~/tutorials/17-mqtt-integration
python3 mqtt_vision.py --source 0 --broker localhost --show
✅ Next: Tutorial 18 — Grafana Dashboard | Back to Jetson Kit