MQTT vs CoAP vs HTTP for IoT sensor communication in manufacturing

We’re standardizing IoT communication protocols for our AM 2021.2 deployment connecting 500+ devices across three plants. Currently we have a mix of protocols causing integration headaches.

MQTT publish-subscribe model seems popular for manufacturing, offering lightweight messaging and good broker support. CoAP is attractive for resource-constrained sensors due to UDP efficiency. HTTP REST integration is familiar to our development team and works with existing infrastructure.

Need to understand protocol gateway patterns for unified data ingestion into MES. What are the trade-offs in real manufacturing environments? Which protocols have you standardized on and why?

Consider operational aspects beyond technical specs. MQTT requires broker infrastructure - we run clustered Mosquitto with high availability. This adds operational complexity but centralized broker simplifies troubleshooting. Can see all device connections, message rates, and subscriptions in one place. HTTP is stateless so harder to monitor connection health. CoAP tooling is still immature compared to MQTT ecosystem.

HTTP REST has advantages people overlook. It works through corporate firewalls without special configuration. Security teams understand HTTPS and certificate management. Debugging with standard tools like Postman or curl is straightforward. Yes it’s heavier than MQTT but for Ethernet-connected PLCs with plenty of resources, the operational simplicity outweighs protocol efficiency. We use REST for equipment integration, MQTT for sensor telemetry.

CoAP shines for battery-powered wireless sensors. Our temperature monitors run 2+ years on coin cell batteries using CoAP over UDP. The observe pattern is similar to MQTT subscriptions but with much lower overhead. However CoAP lacks mature broker ecosystem compared to MQTT. We use CoAP at edge and translate to MQTT at gateway level for enterprise integration.

After implementing all three protocols across multiple manufacturing sites, here’s comprehensive guidance:

MQTT Publish-Subscribe Model: MQTT excels in manufacturing for several reasons. The publish-subscribe decoupling means devices don’t need direct knowledge of consumers - sensors publish temperature readings to topics like “plant1/line3/sensor42/temp” and any number of systems can subscribe. This architectural flexibility is invaluable as requirements evolve. Three QoS levels provide reliability guarantees: QoS 0 (fire-and-forget) for high-frequency telemetry, QoS 1 (at-least-once) for important events, QoS 2 (exactly-once) for critical commands. Last Will Testament feature automatically notifies systems when device disconnects unexpectedly. Retained messages let new subscribers immediately get latest values without waiting. Broker handles connection management, authentication, and message routing. Mature ecosystem includes enterprise brokers like HiveMQ, cloud options like AWS IoT Core, and open-source Mosquitto.

CoAP Resource Constraints Optimization: CoAP designed specifically for constrained devices - microcontrollers with 10KB RAM and limited battery power. Uses UDP instead of TCP, eliminating connection overhead and reducing packet size by 60-70% compared to HTTP. Binary protocol is more efficient than text-based alternatives. Observe pattern provides pub-sub capability similar to MQTT but with lower resource usage. However, CoAP has significant limitations: UDP means no built-in reliability (must implement application-level acknowledgments), NAT traversal is problematic, security (DTLS) is complex on constrained devices, and tooling/libraries lag behind MQTT. Best suited for wireless battery-powered sensors where power efficiency is paramount.

HTTP REST Integration Simplicity: HTTP leverages existing web infrastructure and developer knowledge. Standard HTTPS provides security, works through firewalls without special configuration, and integrates easily with enterprise systems. RESTful APIs are intuitive - GET for reading sensor values, POST for commands, PUT for configuration updates. Debugging is straightforward with browser dev tools, Postman, or curl. However, HTTP has overhead: TCP connection establishment, text-based headers, and stateless nature requires connection per request. Polling-based model is inefficient for real-time data compared to push-based MQTT. Best for Ethernet-connected equipment with sufficient resources where operational simplicity and firewall compatibility matter more than protocol efficiency.

Protocol Gateway Patterns: In real deployments, you’ll have mixed protocols. Protocol gateway provides unified integration point. Common pattern: Edge gateway runs multiple protocol servers (MQTT broker, CoAP server, HTTP endpoint), normalizes incoming data to common format, and publishes to enterprise MQTT broker or directly to MES APIs. Gateway handles protocol translation, data validation, buffering during outages, and security enforcement. We use Node-RED for flexible gateway logic - visual programming makes protocol bridging accessible to operations team. Another pattern: cloud-based protocol gateways like AWS IoT Core or Azure IoT Hub support multiple protocols with managed infrastructure. For AM 2021.2 specifically, implement gateway that exposes unified REST API for MES consumption regardless of device protocol.

Recommendation for Your 500+ Device Deployment: Standardize on MQTT as primary protocol with strategic exceptions. Use MQTT for 80% of devices - networked sensors, PLCs, and gateways. The publish-subscribe model scales well to hundreds of devices and future growth. Implement CoAP only for battery-powered wireless sensors where power efficiency is critical (likely <20% of devices). Use HTTP REST for specific equipment with vendor-provided REST APIs or where firewall traversal is problematic. Deploy redundant MQTT broker cluster for high availability. All protocols converge at gateway layer before feeding MES, providing abstraction and flexibility for future protocol changes.

Protocol gateway is essential for mixed environments. We run Mosquitto MQTT broker with custom bridges that translate CoAP and HTTP to MQTT topics. This gives unified interface to MES regardless of device protocol. Gateway also handles authentication, rate limiting, and data validation before forwarding to production systems. Single point for monitoring all device communications.